1

For security reasons, I have to store the passwords in an external application.yml (outside the war), which should be loaded by the deployed war on runtime.

Do you know where do I have to place the external configuration file? Do I have to configure some properties?

Thank you in advance!

2 Answers 2

3

I assume you have a war file which contains a spring-boot application, in general there are more options to manage your properties, check out the document here: https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html

I will recommend you 2 different approaches:

  1. Set your properties as environment variables, there is much easier way to manage properties if you have a separate container for your application.
  2. Otherwise spring provides you the possibility to override properties using commandline argument, you can do something like: java -jar myproject.war --spring.config.location=file:/default.properties
Sign up to request clarification or add additional context in comments.

1 Comment

Should it be an application.properties file? Or can I also use application.yml? I tried overried the property but this is not working: -Dspring.config.location=file:D:\tomcat\..\webapps\application-develop.yml
0

If you want to store confidential data in the server, then please add <Environment> to the context.xml file of tomcat server. Example: <Environment name="user.password" value="XXXXXXXX" type="java.lang.String" override="false"/>. You can access them as properties in spring context.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.