0

I'm using this command line in order to start my service locally:

mvn -pl rep-digital-api clean compile spring-boot:run \
  -Dspring-boot.run.arguments=--spring.config.additional-location=front-pre-props.properties

pre profile is activated since front-pre-props.properties contains spring.profiles.active=pre.

Into default application-dev.properties I've set this property:

api.path-web=web

Nevertheless, I need to simulate pre profile into my local environment. So I need to change this property value:

 api.path-web=other-path

Nevertheless, this property is not overriden.

Also I've tested it seting -Dapi.path-web=other-value in to mvn command, but it doesn't work...

Any ideas?

Jordi
  • 20,868
  • 39
  • 149
  • 333
  • Where is your file front-pre-props.properties located? If its in classpath, that is, under resources, then you don't need to define the spring.config.additional-location. By default spring-boot picks up these locations : DEFAULT_SEARCH_LOCATIONS = "classpath:/,classpath:/config/,file:./,file:./config/"; – Mohit Singh Dec 23 '19 at 10:48
  • It's into my filesystemm outside of my project. – Jordi Dec 23 '19 at 10:49
  • In your case then you need to specify the locations as: file:./absolutepath/front-pre-props.properties – Mohit Singh Dec 23 '19 at 10:59
  • Could you provide any more helping code, please? I mean, how do I specify this value? – Jordi Dec 23 '19 at 11:13
  • Please check my answer – Mohit Singh Dec 23 '19 at 12:12

1 Answers1

0

If you are trying to add a file from the file system, you need to set the value of property spring.config.additional-location to file:/pathtofile/yourfile.properties.

Lets say your file front-pre-props.properties is in path /Users/demo/front-pre-props.properties

Then you can execute the run command as :

mvn -pl rep-digital-api -Dspring.config.additional-location=“file:/Users/demo/front-pre-props.properties” clean compile
spring-boot:run
Mohit Singh
  • 496
  • 2
  • 11