这是一个在代码中设置端口的 Kotlin 方法:fun main(args: Array<String>) { runApplication<TestApplication>(*args) { setDefaultProperties(mapOf( "server.port" to 8081 )) } }
server.port=8080
。此配置位于org.springframework.boot.autoconfigure.web
下的ServerProperties.class
类中。 - Atif