分享知识-快乐自己: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.
面对过去无怨无悔,把握现在充满信心,备战未来无所畏惧。保持信念,克服恐惧!一点一滴的积累,一点一滴的沉淀,学技术需要不断的积淀!
分享知识-快乐自己:SpringBoot 使用注解API的方式定义启动端口号的更多相关文章
- 分分享知识-快乐自己: @Component注解的使用
@controller 控制器(注入服务) 用于标注控制层,相当于struts中的action层 @service 服务(注入dao) 用于标注服务层,主要用来进行业务的逻辑处理 @repositor ...
- 分享知识-快乐自己:Java常用API总结
1):java.io.BufferedReader类(用于从文件中读入一段字符:所属套件:java.io) 1. 构造函数BufferedReader(java.io.FileReader FileR ...
- 分享知识-快乐自己:solr 伪集群搭建
前言:在你搭建集群之前先去搭建一个单机版的 跳转 Solr 集群构建图: 1):部署(4个)Tomcat 下载 更改每一个 tomcat 启动端口号: [root@VMSolr tomcat_clus ...
- dubbo与springboot的三种整合方式
SpringBoot与dubbo整合的三种方式:1.导入dubbo-starter,在application.properties配置属性,使用@Service暴露服务,使用@Reference引用服 ...
- springboot+jwt做api的token认证
本篇和大家分享jwt(json web token)的使用,她主要用来生成接口访问的token和验证,其单独结合springboot来开发api接口token验证很是方便,由于jwt的token中存储 ...
- spring jwt springboot RESTful API认证方式
RESTful API认证方式 一般来讲,对于RESTful API都会有认证(Authentication)和授权(Authorization)过程,保证API的安全性. Authenticatio ...
- SpringBoot 构建RestFul API 含单元测试
相关博文: 从消费者角度评估RestFul的意义 SpringBoot 构建RestFul API 含单元测试 首先,回顾并详细说明一下在快速入门中使用的 @Controller . @RestC ...
- 最新学习springboot 配置注解
一.概述 Spring Boot设计目的是用来简化新Spring应用的初始搭建以及开发过程.Spring Boot并不是对Spring功能上的增强,而是提供了一种快速使用Spring的方式. ...
- Spring SpringMVC SpringBoot SpringCloud 注解整理大全
Spring SpringMVC SpringBoot SpringCloud 注解整理 才开的博客所以放了一篇以前整理的文档,如果有需要添加修改的地方欢迎指正,我会修改的φ(๑˃∀˂๑)♪ Spri ...
随机推荐
- 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 ...
- pojo和vo有什么区别
pojo 是Plain Old Java Object的缩写,就是javabean.vo是view object的缩写,就是用于页面显示的javabean.vo就是pojo.只是通途上的用于携带页面显 ...
- springboot输出日志到指定目录,简单粗暴,springboot输出mybatis日志
springboot官方文档地址https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot- ...
- Multicast注册中心
1 2 3 4 提供方启动时广播自己的地址. 消费方启动时广播订阅请求. 提供方收到订阅请求时,单播自己的地址给订阅者,如果设置了unicast=false,则广播给订阅者. 消费方收到提供方地址时, ...
- easyNetq demo
本demo包含一个类库,2个console程序 1.新建类库 MQHelper,控制台程序 consumer和proc ,控制台程序引用MQHelper 2.使用nuget安装easynwtq 和 ...
- CentOS 配置网络
1.编辑ifcfg-eth0 vi /etc/sysconfig/network-scripts/ifcfg-eth0 2.修改NOBOOT=yes 3.重启服务 service network re ...
- 【LeetCode从零单排】No.135Candy(双向动态规划)
1.题目 There are N children standing in a line. Each child is assigned a rating value. You are giving ...
- c# combobox 绑定枚举方式
建立一个类 : using System; using System.Collections.Generic; using System.Linq; using System.Text; using ...
- 【BZOJ3110】[Zjoi2013]K大数查询 树套树
[BZOJ3110][Zjoi2013]K大数查询 Description 有N个位置,M个操作.操作有两种,每次操作如果是1 a b c的形式表示在第a个位置到第b个位置,每个位置加入一个数c,如果 ...
- (转)ConcurrentModificationException异常原因和解决方法
原文地址: http://www.cnblogs.com/dolphin0520/p/3933551.html 一.ConcurrentModificationException异常出现的原因 先看下 ...