With java I can do the following to change the tomcat port:
java -jar spring-5.jar --server.port=8083
That works for changing the default 8080 port in my yml file but what if I also want to change the default mongo db port:
spring:
data:
mongodb:
database: test
host: localhost
port: 27017
can I do:
java -jar spring-5.jar --mongodb.port=27018
Will the above work? I could not find any docs on how to change the mongodb port in a spring boot project once compiled into a JAR.
像这样做,
--spring.data.mongodb.port=27018
您可以尝试以下方法:
java -jar spring-5.jar --spring.data.mongodb.port=27018
There're many ways to overwrite the configure in the jar package. Here are some common ways, try one of them:
application.properties
on your work directory. java -Dspring.data.mongodb.port=27018 -jar the.jar
jar -jar the.jar --spring.data.mongodb.port=27018
. Don't forget to pass the args
from main()
to SpringApplication.run
. See https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html for more information
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.