Application.properties outside the jar file, like

As stated in spring-boot-reference :

In your path to the application class (for example, inside your jar) you can have application.properties, which provides a reasonable default property value for the name. When working in a new environment, application.properties can be provided outside of your bank, which cancels the name

I put duplicate application.properties with an overridden name in the same path as the jar file, however when starting the application with:

java -jar target/myproject-0.0.1-SNAPSHOT.jar

The value of the name is not overridden, it still refers to one inside application.properties inside the jar file. I also tried:

java -Dspring.config.location=/target/application.properties -jar target/myproject-0.0.1-SNAPSHOT.jar

But this will not work, please help.

Edit

When I change the current directory to targetand run it, it works.

java -jar myproject-0.0.1-SNAPSHOT.jar

? ?

+4
2

, : spring boot / .

:

1) application.properties ./, ./config/ .

2) -Dspring.config.location:

$ java -Dspring.config.location=target/application.properties -jar target/myproject-0.0.1-SNAPSHOT.jar
+8

config conig, , .

+2

Source: https://habr.com/ru/post/1654216/


All Articles