大佬教程收集整理的这篇文章主要介绍了更改 spring-boot 2.4.4 上的默认 Web 服务器,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用 Spring Boot 2.4.4,我会将默认的 Web 服务器 tomcat 更改为 undertow 或 JHetty,但我发现同时使用 Gradle 或 Maven 非常困难。
旧文档公开了如何操作,但我确信一切都已更改,因为现在核心库中嵌入了 tomcat、undertow 和 jetty 配置:
https://docs.spring.io/spring-boot/docs/2.1.9.RELEASE/reference/html/howto-embedded-web-servers.html
2.4.4 版本是怎么做的?
版本之间没有变化。这在 Spring Boot 2.4.4 参考指南中有很好的描述,就在 3.1. Use Another Web Server 部分。基本上,更改包括两个步骤:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<!-- Exclude the tomcat dependency -->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
请不要忘记注意参考指南中可能与您相关或不相关的同一部分中的以下引用:
Servlet API 的版本已被覆盖,因为与 tomcat 9 和 Undertow 2.0 不同,jetty 9.4 不支持 Servlet 4.0。
,按照三个步骤更改默认的 Web 服务器,更改 pom.xml 中的配置。
1.排除默认网络服务器。
2.包括必要的网络服务器。
3.Maven 更新。
例如
代替这个
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
添加这个
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
为必要的服务器添加适当的 Web 服务器依赖项。
以上是大佬教程为你收集整理的更改 spring-boot 2.4.4 上的默认 Web 服务器全部内容,希望文章能够帮你解决更改 spring-boot 2.4.4 上的默认 Web 服务器所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。