import org.springframework.beans.factory.annotation.Value;
@Value("${server.port}")private String serverPort;搞定!