Spring Boot程序获取tomcat启动端口

package com.geostar.geostack.git_branch_manager.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties
public class MyConfig {

    @Value("${server.port:8080}")
    private int port;

    public int getPort() {
        return port;
    }
}

 

via:https://blog.csdn.net/russle/article/details/82563399

posted @ 2019-01-16 16:09  Nihaorz  阅读(2402)  评论(0编辑  收藏  举报