Defining System Properties in Spring Boot Plugin

前端 未结 1 760
无人及你
无人及你 2021-01-25 04:26

I would like to specify some system properties in my applicatio (deterined at compile time).

I am using the spring boot maven plugin to compile

Currently, accor

相关标签:
1条回答
  • 2021-01-25 05:13

    Java system properties which you add are only accessible by the process they are added to.So even if you manage to add some system properties during the Maven build, it will no longer be there when the build is done.

    What will happen if you distribute your jar to someone else. How do you expect these properties to be available?

    Solution

    Refer this post to see how to access the artifactId and version at runtime In a similar fashion you can add the timestamp entry as well to the src/main/resources/project.properties

    buildTimestamp=${timestamp}
    

    timestamp is not a pre-defined property like project.version or project.artifactId.So you will have to set extract the timestamp from the Maven property ${maven.build.timestamp} and set it as value to your timestamp property. This is already answered in this question.

    0 讨论(0)
提交回复
热议问题