IDEA使用maven创建工程,编译后配置文件没有加载到classes里面
IDEA使用maven创建工程,编译后配置文件没有加载到classes里面,试了很多办法,在网上找了很多的帖子,都没有用,后面问了一位大佬终于解决了问题.
在pom.xml文件中加上下列xml配置
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
<include>**/*.yml</include>
<include>**/*.p12</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>**/*.xml</include>
<include>**/*.yml</include>
<include>**/*.yaml</include>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
</build>
在IDEA中使用Maven创建的工程,编译后发现配置文件没有被加载到classes目录下。经过一系列尝试和搜索无果后,最终从专业人士那里得到了解决方案。关键在于修改pom.xml的build部分,添加resources标签,明确指定包含.java目录和.resources目录下的.xml、.properties等配置文件,确保它们在编译后能被正确加载。
1324

被折叠的 条评论
为什么被折叠?



