原文 :http://blog.csdn.net/kangkanglou/article/details/78585997
项目需要提供一个当前项目版本号的接口。直接获取 pom 文件中的版本号
步骤:
1、application.properties 文件version=${project.version}2、类中@Value("${version}")private String version;复制代码
但是:Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'project.version' in value "${project.version}"
我的 pom 文件:
解决:If you are using the spring boot parent pom the default placeholders have been re-configured to not conflict with the ${} syntax of spring itself.
To replace the maven properties use @ - so @project.version@ instead of ${project.version}.
filtering of the application.properties file is enabled by default.
application.properties 文件
version=@project.version@