直接上报错信息:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Sep 04 17:58:31 CST 2018
There was an unexpected error (type=Not Found, status=404)
然后是解决办法:
1.pom.xml文件中的红色部分注释掉,或者直接拷贝下面的依赖
<!-- tomcat 的支持. -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<!--<scope>provided</scope> idea需要注释掉,idea编译的时候找不到provided包-->
</dependency>
2.在和spring-boot启动类同级新建一个类 如下:
@Configuration
public class CommonConfiguration {
@Bean
public EmbeddedServletContainerFactory embeddedServletContainerFactory() {
ConfigurableEmbeddedServletContainer factory = new TomcatEmbeddedServletContainerFactory();
factory.setDocumentRoot(new File("E:\\idea_workspace\\my-springboot-jsp\\src\\main\\webapp"));
return (EmbeddedServletContainerFactory) factory;
}
}
最后是 重启~ 然后就是搞定~