出现这个问题是pom.xml没有配置resource插件,如果java文件夹没有配置文件就可以不配,而如果有就需要配置了,否则上线发现没有项目启动不了。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>add-resource</id>
<phase>initialize</phase>
<goals>
<goal>add-resource</goal>
</goals>
</execution>
<execution>
<id>add-source</id>
<phase>initialize</phase>
<goals>
<goal>add-source</goal>
</goals>
</execution>
</executions>
<configuration>
<outputDirectory>${pom.basedir}/target/classes</outputDirectory>
<resources>
<resource>
<directory>${pom.basedir}/src/main/java</directory>
<filtering>true</filtering>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.xls</include>
<include>**/*.xlsx</include>
<include>**/*.jpg</include>
<include>**/*.ftl</include>
</includes>
</resource>
</resources>
<sources>
<source>${pom.basedir}/src/main/java</source>
</sources>
</configuration>
</plugin>
这篇博客讨论了在Maven项目中,由于缺少resource插件配置导致的资源文件未打包到最终jar或war的问题。文章指出,如果`src/main/java`目录下存在配置文件,必须在pom.xml中配置`build-helper-maven-plugin`,以确保.properties、.xml等文件在项目部署时能够被正确处理。配置包括添加资源和源代码的路径,并指定了包含的文件类型。

2796

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



