方式1: @Autowired private Environment environment; String port = environment.getProperty("server.port");