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.

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

  • 相关阅读:
    PHP 魔术常量
    PHP 魔术方法
    php函数serialize()与unserialize()
    10 件有关 JavaScript 让人费解的事情
    windows下安装Python2和Python3共存
    SQL 行转列===列转行
    Redis 分布式锁
    RabbitMQ
    @Autowired
    AOP 日志切面
  • 原文地址:https://www.cnblogs.com/mlq2017/p/9943678.html
Copyright © 2011-2022 走看看