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
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