java.lang.IllegalArgumentException 为了防止内存泄漏,jdbc驱动程序已强制取消注册 win10 64位系统中安装多个jdk版本的切换问题

## 具体错误如下:*
(1)
java.lang.IllegalArgumentException
at org.springframework.asm.ClassReader.(Unknown Source)
at org.springframework.asm.ClassReader.(Unknown Source)
at org.springframework.asm.ClassReader.(Unknown Source)
at org.springframework.core.type.classreading.SimpleMetadataReader.(SimpleMetadataReader.java:52)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80)
at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:101)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:76)
at org.springframework.context.annotation.ConfigurationClassParser.getImports(ConfigurationClassParser.java:298)
at org.springframework.context.annotation.ConfigurationClassParser.getImports(ConfigurationClassParser.java:300)
at org.springframework.context.annotation.ConfigurationClassParser.getImports(ConfigurationClassParser.java:300)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:230)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:153)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:130)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:285)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:223)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:630)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4745)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
(2)
警告: Web应用程序 [MyMessageBoard] 注册了JDBC驱动程序 [com.mysql.jdbc.Driver],但在Web应用程序停止时无法注销它。 为防止内存泄漏,JDBC驱动程序已被强制取消注册。
四月 20, 2019 6:31:57 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
警告: The web application [MyMessageBoard] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: java.lang.Object.wait(Native Method) java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143) java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:164) com.mysql.jdbc.NonRegisteringDriver$1.run(NonRegisteringDriver.java:93)
四月 20, 2019 6:31:57 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
警告: The web application [MyMessageBoard] appears to have started a thread named [Thread-3] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: java.lang.Thread.sleep(Native Method) org.apache.log4j.helpers.FileWatchdog.run(FileWatchdog.java:103)

解决办法:

当这两个错误同时出现时一般是第一个错误造成的,第一个错误主要是因为spring版本与Java版本不对应导致的(下面解决均以项目为spring 3.X版本为例)
spring 3.X版本支持到java7
spring 4.X版本支持Java8最低支持到Java6
第一步:
根据自己项目spring版本对照以上spring版本更换jdk版本,下面以1.8切换到1.7为例
1.为了从jdk1.8切换到1.7,首先做的是将环境变量中的JAVA_HOME值改成1.7的安装路径。这个是必须做的。做完这个在cmd下输入Java -version查看是否切换,否则执行第2步
2.将环境变量Path路径中的%JAVA_HOME%\bin值移到最前面
第二步:修改myeclipse的配置
1.Window–>Preferences–>java–>Compiler–>改为1.7版本
2.Window–>Preferences–>java–>Installed JREs–>改为jdk1.7
3.Window–>Preferences–>Servers–>Runtime–>选择你的Tomcat–>Edit–>JRE改为jdk1.7
完成以上两步后,问题就会得到解决,如果还报第二个错,你就应该检察一下你的数据库连接代码部分是否有错了。

附:一个非常好的学习网站:https://how2j.cn?p=37994

你可能感兴趣的:(后端,SSM)