java major version: 51,Unsupported major.minor version 51.0的原因与解决办法
報錯:
[ERROR] - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceTypeService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'serviceTypeMapper' defined in file [/opt/webapps/APIService/WebRoot/WEB-INF/classes/com/mfqapi/dao/ServiceTypeMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory': : Error loading class [com.zaxxer.hikari.HikariDataSource] for bean with name 'dataSource' defined in class path resource [spring-application.xml]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: com/zaxxer/hikari/HikariDataSource : Unsupported major.minor version 51.0 (unable to load class com.zaxxer.hikari.HikariDataSource); nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [com.zaxxer.hikari.HikariDataSource] for bean with name 'dataSource' defined in class path resource [spring-application.xml]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: com/zaxxer/hikari/HikariDataSource : Unsupported major.minor version 51.0 (unable to load class com.zaxxer.hikari.HikariDataSource)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:307)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:609)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:469)
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:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5017)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5531)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'serviceTypeMapper' defined in file [/opt/webapps/APIService/WebRoot/WEB-INF/classes/com/mfqapi/dao/ServiceTypeMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory': : Error loading class [com.zaxxer.hikari.HikariDataSource] for bean with name 'dataSource' defined in class path resource [spring-application.xml]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: com/zaxxer/hikari/HikariDataSource : Unsupported major.minor version 51.0 (unable to load class com.zaxxer.hikari.HikariDataSource); nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [com.zaxxer.hikari.HikariDataSource] for bean with name 'dataSource' defined in class path resource [spring-application.xml]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: com/zaxxer/hikari/HikariDataSource : Unsupported major.minor version 51.0 (unable to load class com.zaxxer.hikari.HikariDataSource)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1199)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1091)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:304)
... 23 more
錯誤原因:
這是開發環境中的jdk版本和項目運行的服務器上的jdk的版本不一致造成的,原來開發環境用的是jdk1.7,而服務器運行環境用的是jdk1.6。
解決:
重新替換服務器上的jdk版本為1.7或者將開發環境的jdk換成1.6重新編譯,只要保證兩個jdk版本兼容即可。
總結
以上是生活随笔為你收集整理的java major version: 51,Unsupported major.minor version 51.0的原因与解决办法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php 上个月天数,php日期所在月的天
- 下一篇: java 输入 方程,用java 编写一