I
I
IvanN7772020-12-24 09:34:28
Java
IvanN777, 2020-12-24 09:34:28

How to take out the config from the Spring application (external customizable)?

Configs must be configured in such a way that they are not stored in the source code, but are substituted depending on the environment directly on the server.


I used to put values ​​in ENV variables.
In this way, you can cut out a regular config, for example.
<resources>
    <resource>
    <directory>src/main/resources</directory>
    <filtering>true</filtering>
    <excludes>
    <exclude>**/application.properties</exclude>
    </excludes>
    </resource>
</resources>


But how to properly connect to the outside.
You can of course do something like
@PropertySource(ignoreResourceNotFound=true, value="xxx")
but not sure if this is correct.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan, 2020-12-24
@IvanN777

The answer is easily found by a search engine.
Here is a useful article - https://www.baeldung.com/spring-properties-file-ou... The
paths that Spring searches for configuration files by default:

A /config subdirectory of the current directory
    The current directory
    A classpath /config package
    The classpath root

Here is a similar question on SO
https://stackoverflow.com/questions/26744060/exclu...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question