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
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With