发现无论怎么改都还是指向8001
所以换一种方法
通过
结果
代码
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
@RequestMapping("/test")
@Configuration
public class ConfigController {@Beanpublic WebServerFactoryCustomizer<ConfigurableWebServerFactory> customPort() {return factory -> factory.setPort(7070); // 将应用的端口设置为 7070}@GetMapping("/config") // 更明确地指定为处理 GET 请求public String testConfig() {System.out.println("=====获取的订单服务地址为:" );return "success";}
}