你可以传入各个属性作为命令行参数。例如,如果要设置server.port,则在启动可执行jar时可以执行以下操作:
java -jar your-app.jar --server.port=8081
另外,如果你使用的是
mvn spring-boot:run:
mvn spring-boot:run -Drun.arguments="--server.port=8081"
你还可以
spring-boot:run在应用程序中配置参数,
pom.xml这样就不必每次都在命令行上指定它们:
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <arguments> <argument>--server.port=8085</argument> </arguments> </configuration></plugin>



