C/C++教程

解决Property ‘mapperLocations‘ was not specified or no matching resources found问题

本文主要是介绍解决Property ‘mapperLocations‘ was not specified or no matching resources found问题,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

问题描述

在这里插入图片描述
在编写mybatis映射文件时,将XML文件放到了包下,而不是resources文件夹下,maven在打包的时候,默认是不会把xml文件打包编译,因此需要手动在pom文件配置,让maven在编译时把xml文件也进行输出。

解决方案

在pom文件中加入以下代码

<!-- 项目打包时会将java目录中的*.xml文件也进行打包 -->
    <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
    </build>
这篇关于解决Property ‘mapperLocations‘ was not specified or no matching resources found问题的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!