Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

application.properties is ignored, taken from somewhere else

I am having a strange issue (i am new in spring-boot), this is my application.properties

server.port=8087
spring.datasource.url:${DB_URL}
spring.datasource.username=${DB_USER_NAME}
spring.datasource.password=${DB_PASSWORD}
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
spring.jpa.show-sql=true

When runing it localy, it works just fine. BUT when using a staging server, the changes on the code (controller for example) is taken, but the changes in application.properties is not! server.port for example on my local machine is 8807, but on the staging server is 8080.

Is there some place that the application is taking configuration from?

Thanks for your help

like image 776
Bara' ayyash Avatar asked May 03 '17 13:05

Bara' ayyash


People also ask

Where are application properties stored?

You will need to add the application. properties file in your classpath. If you are using Maven or Gradle, you can just put the file under src/main/resources . If you are not using Maven or any other build tools, put that under your src folder and you should be fine.

What is the alternative to application properties file?

YAML is a convenient format for specifying hierarchical configuration data. This can be more readable than its property file alternative since it does not contain repeated prefixes.

What is application properties used for?

Properties files are used to keep 'N' number of properties in a single file to run the application in a different environment. In Spring Boot, properties are kept in the application. properties file under the classpath. Note that in the code shown above the Spring Boot application demoservice starts on the port 9090.


1 Answers

There is a documented list of sources properties will be loaded from and in what priority.

application.properties is at priority 14 of 17, where 1 is highest priority

like image 188
Pär Nilsson Avatar answered Oct 20 '22 12:10

Pär Nilsson