Maven将属性文件添加到jar文件中 [英] Maven add properties file to jar file
本文介绍了Maven将属性文件添加到jar文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用以下插件配置制作一个jar文件,我想在输出jar中的同一位置包含非java src文件,如上所述这里。
I am using the following plugin configuration to make a jar file and I want to include non-java src files in the same place in the output jar as described here.
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<!-- include non-java src files in the same place in the output jar -->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
以上不起作用,以下情况也不起作用:
The above does not work and neither does the following:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<!-- include non-java src files in the same place in the output jar -->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
推荐答案
在<...中的同一个包(文件夹)中添加文件code> src / main / resources 而不是 src / main / java
或查看我的回答使用maven - clean包,xml源文件不包含在类路径中
Add file in the same package (folder) in src/main/resources
instead of src/main/java
or see my answer With maven - clean package, xml source files are not included in classpath
这篇关于Maven将属性文件添加到jar文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文