I started to use maven to create a Spring boot app.
I wan't to deploy the project using maven commands. Here is my file application.properties
spring.config.import=optional:file:env.properties
spring.datasource.url=${DATA_SOURCE_URL}
spring.datasource.username=${DB_USER}
spring.datasource.password=${DB_PASSWORD}
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.jpa.hibernate.ddl-auto = update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
jwt.secret = ${SECRET}
As you can see I import a file named env.properties, however I wan't to import it every time I use the mvn clean install command.
Can you help me to find the correct command or to configure my pom.xml plugins ?
Here you are:
To import application properties from
pom.xml
file you have to:Set the name of the parameter and value in
<properties>
tag:And second one you have to add
spring-boot-maven-plugin
andresource
that point toapplication.properties
.And after it in
application.properties
file you will able to access the parameter as next one:Also if you didn't like this approach you could use Properties Maven Plugin