I would like to create a configuration file where i will store connection to an external application (SAP). I have the connection hard coded in my code but read that its not good idea so i am trying to move it to a configuration properties file.
Also you can set value of the configuration interface directly on production server, e.g. with help of environment variables.
If you like your properties to be runtime-modifiable - you can choose to store configuration properties in the database. Then you can use SourceType.DATABASE mode for the configuration interface properties.
I read the documentation, but couldn’t make full understanding out of it. It would be great if you perhaps give me an example, that is creating a template properties file with dummy data and specifying in which directory of the project folder i can add that file.
Use separate Spring profile to store production values.
Create “prod-app.properties” file nearby to the app.properties file (com/company/projectname) in the core module.
Put production values to the file, like below:
sap.jco.ashost = 10.0.0.1
sap.jco.sysnr = 77
Enable “prod” Spring profile on a target server to enable using of the prod-app.properties.
E.g. if you are using Tomcat server on Windows, then you can add this line to the setenv.bat script:
set CATALINA_OPTS=%CATALINA_OPTS% -Dspring.profiles.active=prod
Another option to pass application property values on the target server is to use environment variables.
E.g. to define such environment variables: