在java下面配置xml导致idea编译失败
1.今天遇到一个问题在java配置dao.xml的时候导致,idea编译失败
然后把pom.xml上面的
<build> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> </resource> </resources> </build>
去掉之后报Invalid bound statement (not found): com.supplychain.dao.EmailLoginMapper.getEmail
错误,因为pom.xml的那段代码是为了扫描java下面的xml,xml放到resource下面则不用配置,
然后我就陷入了死循环当中。
2.解决方法加入
<build> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> <include>**/*.properties</include> </includes> <filtering>true</filtering> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.xml</include> <include>**/*.properties</include> <include>**/*.yml</include> </includes> <filtering>true</filtering> </resource> </resources> </build>
应为idea默认是编译resource下面的所有文件和java下面的所有文件
当在pom.xml下面配置build的时候,应为我只配置了java的build,所以只能加载
java下面的所有文件,不能配置resource下面的,导致编译yml失败
加上
<resource> <directory>src/main/resources</directory> <includes> <include>**/*.xml</include> <include>**/*.properties</include> <include>**/*.yml</include> </includes> <filtering>true</filtering> </resource>
Springboot启动的时候默认加载resouce和java中的文件
3.或者直接把xml放到resource目录下面,idea默认就编译了,也不用这么麻烦
我遇到的情况是编译resource失败的情况,遇到这个问题的希望这篇文章能对你有所帮助!!