tomcat版本

这篇博客介绍了在使用Tomcat 6.0.33版本时遇到的内存泄漏问题,包括JDBC驱动未正确注销、线程无法停止等错误。博主建议使用更早的版本或升级到Tomcat 7,并整理相关jar包来避免此类问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

tomcat版本使用6.0.33的时候会出现很多问题,此版本引入了内存管理机制,很多jar包不符合标准。会出现如下等信息

十一月 18, 2011 2:17:12 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application registered the JDBC driver [org.logicalcobwebs.proxool.ProxoolDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
十一月 18, 2011 2:17:12 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application registered the JDBC driver [net.sourceforge.jtds.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
十一月 18, 2011 2:17:12 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application appears to have started a thread named [HouseKeeper] but has failed to stop it. This is very likely to create a memory leak.
十一月 18, 2011 2:17:12 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application appears to have started a thread named [Thread-5] but has failed to stop it. This is very likely to create a memory leak.
十一月 18, 2011 2:17:12 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application appears to have started a thread named [ActiveMQ Transport: tcp:///192.168.0.1:61616] but has failed to stop it. This is very likely to create a memory leak.
十一月 18, 2011 2:17:12 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application appears to have started a thread named [ActiveMQ Transport: tcp:///192.168.0.1:61616] but has failed to stop it. This is very likely to create a memory leak.
十一月 18, 2011 2:17:12 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application appears to have started a thread named [InactivityMonitor ReadCheck] but has failed to stop it. This is very likely to create a memory leak.
十一月 18, 2011 2:17:12 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application appears to have started a thread named [InactivityMonitor WriteCheck] but has failed to stop it. This is very likely to create a memory leak.
十一月 18, 2011 2:17:12 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application appears to have started a thread named [InactivityMonitor Async Task: java.util.concurrent.ThreadPoolExecutor$Worker@166ec4c[State = 0, empty queue]] but has failed to stop it. This is very likely to create a memory leak.
十一月 18, 2011 2:17:12 下午 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
严重: The web application created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@dba72d]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@bc82f9]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.

但是有时候不影响工程正常启动,建议使用老一点的版本或者使用tomcat7,把jar包整理一下。

proxool.0.9.1基础上做了修改。 改jar名称为:proxool-0.9.1.1,主要修改为以下3点: 1.解决不能Unregister jdbc driver的内存泄露问题。 十二月 02, 2013 8:19:43 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc SEVERE: The web application [/xxx] registered the JDBC driver [org.logicalcobwebs.proxool.ProxoolDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. 十二月 02, 2013 8:19:43 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc SEVERE: The web application [/xxx] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. 十二月 02, 2013 8:19:43 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc SEVERE: The web application [/xxx] registered the JDBC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. 2.解决housekeeper内存泄露问题 3.解决与spring配合时,只能在spring的定义中以bean方式加载proxool的问题。(使用servlet方式加载也可以,只是在启动时报错) 加载方式修改为: xmlFile /WEB-INF/conf/proxool.xml org.logicalcobwebs.proxool.configuration.ListenerConfigurator 与spring配合使用时,本加载需要放在spring前面 org.logicalcobwebs.proxool.configuration.ListenerConfigurator org.springframework.web.context.ContextLoaderListener 4.修正了proxool在多线程环境下的的错误。
<think>根据用户的问题,用户想要在Spring Boot项目中锁定Tomcat版本。Spring Boot默认使用Tomcat作为内嵌服务器,并且每个Spring Boot版本都对应着一个特定的Tomcat版本。如果用户想要覆盖默认的Tomcat版本,可以通过Maven或Gradle进行配置。 步骤: 1. 确定当前使用的Spring Boot版本默认的Tomcat版本(可选,但不是必须,因为我们的目的是覆盖它)。 2. 在项目的构建文件中(Maven的pom.xml或Gradle的build.gradle)指定要使用的Tomcat版本。 以Maven项目为例: 在pom.xml文件中,可以通过属性`<tomcat.version>`来指定Tomcat版本。例如,如果我们想使用Tomcat 9.0.50版本,可以这样配置: ```xml <properties> <tomcat.version>9.0.50</tomcat.version> </properties> ``` 或者,如果用户使用Gradle,可以在build.gradle中设置: ```gradle ext['tomcat.version'] = '9.0.50' ``` 但是,请注意,Spring Boot对Tomcat版本有兼容性要求。因此,在覆盖版本时,需要确保所选版本与当前使用的Spring Boot版本兼容。否则可能会导致运行时错误。 另外,用户也可以直接排除默认的Tomcat依赖,然后引入指定版本Tomcat依赖。但是Spring Boot官方推荐使用属性覆盖的方式。 示例(Maven): 在pom.xml中,我们可以通过以下方式覆盖: ```xml <properties> <tomcat.version>9.0.50</tomcat.version> </properties> ``` 这样,Spring Boot的starter-web就会使用指定的Tomcat版本。 如果用户想要查看当前项目使用的Tomcat版本,可以通过Maven命令: ``` mvn dependency:tree | grep tomcat ``` 或者Gradle命令: ``` gradle dependencies | grep tomcat ``` 注意:在覆盖版本时,建议选择Spring Boot官方支持的Tomcat版本,以避免兼容性问题。可以查阅Spring Boot官方文档,了解当前Spring Boot版本所支持的Tomcat版本范围。 引用说明:根据之前提供的引用内容,没有直接关于锁定Tomcat版本的信息,因此我们主要基于Spring Boot的常规配置方式回答。 生成相关问题: 1. 如何查看Spring Boot当前使用的Tomcat版本? 2. 覆盖Tomcat版本后出现兼容性问题怎么办? 3. Spring Boot支持哪些Tomcat版本? 4. 除了Tomcat,Spring Boot还支持哪些内嵌服务器? 现在,我们按照用户要求,用中文回答,并注意格式要求。</think>在 Spring Boot 中锁定 Tomcat 版本,可以通过以下步骤实现: ### 1. **覆盖默认的 Tomcat 版本** 在 Maven 或 Gradle 配置中显式指定 Tomcat 版本,这会覆盖 Spring Boot 的默认版本: ```xml <!-- Maven 示例 (pom.xml) --> <properties> <!-- 指定确切的 Tomcat 版本 --> <tomcat.version>9.0.75</tomcat.version> </properties> ``` ```gradle // Gradle 示例 (build.gradle) ext['tomcat.version'] = '9.0.75' ``` ### 2. **验证依赖版本** 执行以下命令检查版本是否生效: ```bash # Maven mvn dependency:tree | grep tomcat # Gradle gradle dependencies | grep tomcat ``` 输出应显示指定的版本,例如:`org.apache.tomcat.embed:tomcat-embed-core:9.0.75` ### 3. **兼容性注意事项** - Spring Boot 每个版本Tomcat 有[特定兼容范围](https://docs.spring.io/spring-boot/docs/current/reference/html/dependency-versions.html)[^2] - 例如 Spring Boot 2.7.x 兼容 Tomcat 9.0.x/10.0.x - 不兼容的版本可能导致启动失败 ### 4. **替代方案:显式声明依赖** 如果属性覆盖无效,可手动添加依赖: ```xml <!-- Maven 显式依赖 --> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-core</artifactId> <version>9.0.75</version> </dependency> ``` ### 5. **版本锁定最佳实践** 建议在 `<dependencyManagement> ` 中锁定所有相关组件: ```xml <dependencyManagement> <dependencies> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-core</artifactId> <version>9.0.75</version> </dependency> <!-- 其他相关组件如 el, websocket 等 --> </dependencies> </dependencyManagement> ``` > **重要提示**:生产环境建议通过 CI/CD 流程验证版本变更,例如使用 `boxfuse run myapp.jar -env=prod` 部署前进行测试[^3]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值