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

操作示例如下:

代码:

  1. @Bean
  2. public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer() {
  3. return new WebServerFactoryCustomizer<ConfigurableWebServerFactory>() {
  4. @Override
  5. public void customize(ConfigurableWebServerFactory factory) {
  6. factory.setPort(8000);
  7. }
  8. };
  9. }

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

  1. @Bean
  2. public EmbeddedServletContainerCustomizer containerCustomizer()
  3. {
  4. return (container -> {container.setPort(1234);});
  5. }

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

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

分享知识-快乐自己:SpringBoot 使用注解API的方式定义启动端口号的更多相关文章

  1. 分分享知识-快乐自己: @Component注解的使用

    @controller 控制器(注入服务) 用于标注控制层,相当于struts中的action层 @service 服务(注入dao) 用于标注服务层,主要用来进行业务的逻辑处理 @repositor ...

  2. 分享知识-快乐自己:Java常用API总结

    1):java.io.BufferedReader类(用于从文件中读入一段字符:所属套件:java.io) 1. 构造函数BufferedReader(java.io.FileReader FileR ...

  3. 分享知识-快乐自己:solr 伪集群搭建

    前言:在你搭建集群之前先去搭建一个单机版的 跳转 Solr 集群构建图: 1):部署(4个)Tomcat 下载 更改每一个 tomcat 启动端口号: [root@VMSolr tomcat_clus ...

  4. dubbo与springboot的三种整合方式

    SpringBoot与dubbo整合的三种方式:1.导入dubbo-starter,在application.properties配置属性,使用@Service暴露服务,使用@Reference引用服 ...

  5. springboot+jwt做api的token认证

    本篇和大家分享jwt(json web token)的使用,她主要用来生成接口访问的token和验证,其单独结合springboot来开发api接口token验证很是方便,由于jwt的token中存储 ...

  6. spring jwt springboot RESTful API认证方式

    RESTful API认证方式 一般来讲,对于RESTful API都会有认证(Authentication)和授权(Authorization)过程,保证API的安全性. Authenticatio ...

  7. SpringBoot 构建RestFul API 含单元测试

    相关博文: 从消费者角度评估RestFul的意义 SpringBoot 构建RestFul API 含单元测试 首先,回顾并详细说明一下在快速入门中使用的  @Controller .  @RestC ...

  8. 最新学习springboot 配置注解

    一.概述      Spring Boot设计目的是用来简化新Spring应用的初始搭建以及开发过程.Spring Boot并不是对Spring功能上的增强,而是提供了一种快速使用Spring的方式. ...

  9. Spring SpringMVC SpringBoot SpringCloud 注解整理大全

    Spring SpringMVC SpringBoot SpringCloud 注解整理 才开的博客所以放了一篇以前整理的文档,如果有需要添加修改的地方欢迎指正,我会修改的φ(๑˃∀˂๑)♪ Spri ...

随机推荐

  1. Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental……

    Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to th ...

  2. pojo和vo有什么区别

    pojo 是Plain Old Java Object的缩写,就是javabean.vo是view object的缩写,就是用于页面显示的javabean.vo就是pojo.只是通途上的用于携带页面显 ...

  3. springboot输出日志到指定目录,简单粗暴,springboot输出mybatis日志

    springboot官方文档地址https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot- ...

  4. Multicast注册中心

    1 2 3 4 提供方启动时广播自己的地址. 消费方启动时广播订阅请求. 提供方收到订阅请求时,单播自己的地址给订阅者,如果设置了unicast=false,则广播给订阅者. 消费方收到提供方地址时, ...

  5. easyNetq demo

    本demo包含一个类库,2个console程序 1.新建类库  MQHelper,控制台程序  consumer和proc ,控制台程序引用MQHelper 2.使用nuget安装easynwtq 和 ...

  6. CentOS 配置网络

    1.编辑ifcfg-eth0 vi /etc/sysconfig/network-scripts/ifcfg-eth0 2.修改NOBOOT=yes 3.重启服务 service network re ...

  7. 【LeetCode从零单排】No.135Candy(双向动态规划)

    1.题目 There are N children standing in a line. Each child is assigned a rating value. You are giving ...

  8. c# combobox 绑定枚举方式

    建立一个类 : using System; using System.Collections.Generic; using System.Linq; using System.Text; using ...

  9. 【BZOJ3110】[Zjoi2013]K大数查询 树套树

    [BZOJ3110][Zjoi2013]K大数查询 Description 有N个位置,M个操作.操作有两种,每次操作如果是1 a b c的形式表示在第a个位置到第b个位置,每个位置加入一个数c,如果 ...

  10. (转)ConcurrentModificationException异常原因和解决方法

    原文地址: http://www.cnblogs.com/dolphin0520/p/3933551.html 一.ConcurrentModificationException异常出现的原因 先看下 ...