zoukankan      html  css  js  c++  java
  • 分享知识-快乐自己:SpringBoot 使用注解API的方式定义启动端口号

    在Spring Boot2.0以上配置嵌入式Servlet容器时EmbeddedServletContainerCustomizer类不存在,经网络查询发现被WebServerFactoryCustomizer替代

    操作示例如下:

    代码:

        @Bean
        public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer() {
            return new WebServerFactoryCustomizer<ConfigurableWebServerFactory>() {
                @Override
                public void customize(ConfigurableWebServerFactory factory) {
                    factory.setPort(8000);
                }
            };
        }

    Spring Boot2.0以下版本:(目前没有自身测试过:2.0以下版本请优先作为参考)

    @Bean
    public EmbeddedServletContainerCustomizer containerCustomizer() 
    {        
        return (container -> {container.setPort(1234);});
    }

    Face your past without regret. Handle your present with confidence.Prepare for future without fear. keep the faith and drop the fear.

    面对过去无怨无悔,把握现在充满信心,备战未来无所畏惧。保持信念,克服恐惧!一点一滴的积累,一点一滴的沉淀,学技术需要不断的积淀!

  • 相关阅读:
    Pentaho
    sympy 解四元一次方程
    install R language on ubuntu
    pyside
    浙江省医院网上挂号
    mtu值相关
    Python 中除法运算需要注意的几点
    idea
    kilim
    good blog
  • 原文地址:https://www.cnblogs.com/mlq2017/p/9943678.html
Copyright © 2011-2022 走看看