记录Maven和Mybatis整合时打包漏掉mapper的xml文件及其它资源

最近把项目组织方式改成Maven,其中遇到了不少问题

最为严重的是,Mybatis启动老是报绑定错误(找不到Mapper对应的 SQL配置),经过一番Google未能解决问题(大家都说是XML没写对之类的),根本就没有怀疑到漏掉XML文件,最后迫不得已,去查看了下 Maven打包后的war文件,才找到问题。

废话不多说,解决方式是,在pom.xml文件中的build节点中,添加如下代码:

<resources>
          <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
           </resource>
</resources>
# Maven 

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×