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>

  就可以了

3.或者直接把xml放到resource目录下面,idea默认就编译了,也不用这么麻烦

  

12-18 13:16