ITWorker
ITWorker

Reputation: 995

"-Drun.profiles=.." is not working when trying to execute Spring Boot jar

I am trying to execute the following:

C:\Users\Homeuser>java -jar -Djasypt.encryptor.password=testpass -Drun.profiles.active=dev C:\testproj\target\test-0.0.1-SNAPSHOT.jar

However, the version that runs uses the properties that are specified in the application-local.properties file, and not from the application-dev.properties file as I expected. I know this because the local version uses an H2 db with fake data, and the -dev profile connects to a real database with real data, and what I saw was the fake data. In my application.properties file, I have the following setting:

spring.profiles.active=local

This problem is only happening when I am building a jar first then executing it. When I use the following command from Eclipse maven run profile:

clean spring-boot:run -Drun.profiles=dev -Djasypt.encryptor.password=testpass

It correctly loads up the expected profile. What am I doing wrong?

Thank you.

Upvotes: 0

Views: 659

Answers (1)

dunni
dunni

Reputation: 44515

The property run.profiles is a property which comes from the spring-boot maven plugin. So it only works if you use that to run your application. If you want to activate a plugin when using the jar command, specify the property spring.profiles.active=dev.

Upvotes: 2

Related Questions