Reputation: 11
I am using Grails 3.3.1 with spring boot. the build tool is gradle. All application related properties are configured in application.yml file.
Now I want to access different .yml files for different environments [development, test etc]. For this I have created different .yml files per environment. The command used to run server is : grails -Dgrails.env=test run-app Now when i access any property, it gives me the values from application-test.yml file which is as expected.
But when I access server.port, it is reading this property from application.yml instead of application-test.yml.
Can anyone help me in running the application by using server.port from application-test.yml file
server: port: 8081
server: port: 8443
I am expecting the server to run on port 8443 as this property is in application-test.yml. But the server runs on port 8081 as mentioned in application.yml
Upvotes: 0
Views: 893
Reputation: 401
You can override the port directly at startup with --server.port
or -Dserver.port
If you want completely different YML, you can set spring.config.location
as a parameter. Here's an example:
# start service
/opt/jdk/bin/java \
-Dserver.port=<your port> \
-jar /opt/service/<your warfile> --spring.config.location=<your YML>
References: How to configure port for a Spring Boot application
Upvotes: 0
Reputation: 11
I could resolve the above issue by adding server.port per environment in the .yml files
development:
dataSource:
dbCreate: none
url: //url
logSql: true
username: //username
password: //password
driverClassName: "oracle.jdbc.driver.OracleDriver"
pooled: true
jmxExport: true
server:
port: 8081
contextPath : /ssp
test:
dataSource:
dbCreate: none
url: //url
username: //username
password: //password
driverClassName: "oracle.jdbc.driver.OracleDriver"
pooled: true
jmxExport: true
logSql: true
server:
port: 8082
contextPath : /ssp
Upvotes: 0