java 内嵌tomcat_(023)Spring Boot之修改内嵌tomcat的3种方式

springboot内嵌了tomcat容器,可以通过3中方式来修改tomcat。(1)修改application.properties文件中属性,比如:server.port=8081server.address=127.0.0.1server.tomcat.accesslog.enabled=trueserver.tomcat.accesslog.directory=d\:/springboot...
摘要由CSDN通过智能技术生成

springboot内嵌了tomcat容器,可以通过3中方式来修改tomcat。

(1)修改application.properties文件中属性,比如:

server.port=8081server.address=127.0.0.1server.tomcat.accesslog.enabled=trueserver.tomcat.accesslog.directory=d\:/springboot/logs

端口:8081

绑定IP:上面的配置只能在浏览器输入localhost:8081或者127.0.0.1访问

启动tomcat的访问日志

tomcat访问日志的路径:D:\springboot\logs\access_log.2019-12-05.log,(2019-12-05是运行时间)

其他配置可以看源码:org.springframework.boot.autoconfigure.web.ServerProperties

(2)实现WebServerFactoryCustomizer接口,并装配到spring容器中,如下:

pom.xml

8f900a89c6347c561fdf2122f13be562.png

961ddebeb323a10fe0623af514929fc1.png

4.0.0

com.edu.spring

springboot_web

1.0.0

springboot_web

http://www.example.com

org.springframework.boot

spring-boot-starter-parent

2.0.4.RELEASE

UTF-8

1.8

1.8

org.springframework.boot

spring-boot-starter-web

View Code

MyWebServerFactoryCustomizer.java

8f900a89c6347c561fdf2122f13be562.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值