- pom中添加如下配置
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<!-- // 分环境打包 todo-->
<!-- <include>application-${profileActive}.yml</include>-->
<include>*.properties</include>
<include>*.xml</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${maven.plugin.version}</version>
<configuration>
<delimiters>
<delimiter>@</delimiter>
</delimiters>
<useDefaultDelimiters>false</useDefaultDelimiters>
</configuration>
</plugin>
</plugins>
2.application.properties加如下配置
version=@project.version@
artifactId=@project.artifactId@
或者xx.yml中添加如下配置
verson: @project.version@
artifactId: @project.artifactId@
直接run项目,再target看是否生效
或者直接mvn package 或者 install看jar中是否生效
用半天解决了这个问题,因为在application.properties中使用 p r o j e c t . v e r s i o n , {project.version}, project.version,{project.artifactId}获取值,然而并获取不到,另外一篇csdn的误导。