springboot项目在idea容易出现找不到页面文件和tomcat报错的问题。故对这两个问题记录一下。
在POM文件下,加入如下设置:
<!-- 使用IDEA开发工具时,需要加上该resources配置,解决webapp/资源目录无效的问题 -->
<resources>
<resource>
<directory>src/main/webapp</directory>
<!--编译的时候把webapp文件放到resources下,必须要放在此目录下才能被访问到 -->
<targetPath>META-INF/resources</targetPath>
<includes>
<include>**/**</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
另外针对dependency部分,要排除对应的tomcat,不然会报错
<!--使用IDEA开发工具时,注释该依赖,否则启动报错;IDEA内置tomcat-->
<!--
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
-->