IDEA maven项目src源代码下的资源文件不自动复制到classes文件夹下

版权声明:不卑不亢,不骄不躁---好男人就是我,我就是曾哥. https://blog.csdn.net/weixin_42884584/article/details/82432892

IDEA maven项目src源代码下的资源文件不自动复制到classes文件夹下,可以在pom.xml中配置

比如说mapper.xml和mapper.java都放在src的com.xx.mapper包下,就要配置了。

如果不想加的话可以把mapper.xml直接放到resource文件夹下即可,但是包名要一致com.xx.mapper。

<!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉。 -->
<build>
	<resources>
	  <resource>
			<directory>src/main/java</directory>
			<includes>
				<include>**/*.xml</include>
			</includes>
		</resource>
	</resources>
</build>

还有就是不希望把所有类型的资源文件都复制到classes,可以通过下面这种方式:

<build>
    <resources>
        <resource>
            <directory>src/main/java</directory>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
    </resources>
</build>

在需要的场景下用,不要乱用哦,乱用可能导致classes目录下没有文件哦。

最好还是配置文件就放到resources目录下,java文件就放到java目录下。就不要配置了。

猜你喜欢

转载自blog.csdn.net/weixin_42884584/article/details/82432892