我想在我的应用中指定一些系统属性(在编译时确定)。在Spring Boot Plugin中定义系统属性
我现在用的是弹簧启动Maven插件编译
目前,根据这个问题:Specify system property to Maven project 我尝试以下设置(然而,这并不工作,因为它是一个不同的插件)
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>application.boot.AppStarter</mainClass>
<systemProperties>
<systemProperty>
<name>application.version</name>
<value>${application.version}</value>
</systemProperty>
<systemProperty>
<name>release.date</name>
<value>${timestamp}</value>
</systemProperty>
</systemProperties>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
如何指定此插件中的属性?
spring-boot-maven-plugin只是创建一个可执行的jar。你想用系统属性做什么?你的意思是说当你执行生成的jar时你需要在属性文件中提供一些属性?重新打包不支持任何systemProperties参数,如http://docs.spring.io/spring-boot/docs/1.2.0.BUILD-SNAPSHOT/maven-plugin/repackage-mojo.html – coderplus 2014-10-26 15:09:01
我想要两件事。 1)Hermes.version maven pom.xml属性和2)构建jar的日期可以在我的代码中访问。如果它们作为系统属性,我可以使用System.getProperty(“”)访问它们 – mangusbrother 2014-10-26 15:46:19