How to reuse properties from application.properties (Spring Boot) in Maven pom.xml?

I would like to define a database url, username, password

in one place. I am currently

application.properties

from

spring.datasource.url=....
spring.datasource.username=sa
spring.datasource.password=00

      

And pom.xml

with

  <plugin>
    <groupId>org.flywaydb</groupId>
    <artifactId>flyway-maven-plugin</artifactId>
    <version>4.1.2</version>
    <configuration>
      <url>....</url>
      <user>sa</user>
      <password>00</password>
    </configuration>
  </plugin>

      

So I probably need to reuse property values ​​defined inapplication.properties

.

This one <password>${spring.datasource.password}</password>

doesn't work. Also I tried

 <systemProperties>
    <systemProperty>
      <name>url</name>
      <value>....</value>
    </systemProperty>
    ...
 </systemProperties>

      

Neither approach works.

+3


source to share


1 answer


You can do the opposite by creating a properties file from your pom file. In your properties file, you should use something like:

password=${pom.password}

      

And your pom file will have something like:

<password>your_db_password</password>

      



Then at:

mvn clean package

      

Maven will create your properties file.

Here is a simple tutorial: Add Maven Creation Information ...

+1


source







All Articles