Spring Boot 2.7.X打war包时外部Tomcat的版本选择

测试环境

Tomcat 10.0.23
Tomcat 9.0.69

最近做Spring Boot项目,选用的是2.7.X版本,本想打个war包在外部Tomcat测试下,于是去Tomcat的官网下了一个Tomcat 10版本,但是折腾了半天,愣是没有跑起来,一时半会也不知道是Tomcat的问题还是war包的问题,于是又去IDEA上看了下内置的Tomcat的版本,是Tomcat 9,难道是版本问题,于是又去Tomcat的官网下载了Tomcat 9版本,这次到是跑了起来,虽然知道应该是版本的问题,但是高版本的Tomcat 10应该会兼容Tomcat 9的,为什么不能兼容呢?其实答案在下载之前已经告诉我们了,只不过可能下载的时候并没有可以留意,下载页面最顶部有这样一段话:

Users of Tomcat 10 onwards should be aware that, as a result of the move from Java EE to Jakarta EE as part of the transfer of Java EE to the Eclipse Foundation, the primary package for all implemented APIs has changed from javax.* to jakarta.*. This will almost certainly require code changes to enable applications to migrate from Tomcat 9 and earlier to Tomcat 10 and later. A migration tool has been developed to aid this process.

常用的主包javax改为了jakarta,因此Tomcat 9上开发的应用不能直接迁移到Tomcat 10。

更加直观的可以直接解压缩Tomcat目录下的lib\servlet-api,9的是javax,10的是jakarta。

猜你喜欢

转载自blog.csdn.net/a7442358/article/details/129067099