1.首先明确代码没有问题,用很简单的代码测试即可
2.异常:
org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [com.naarchi.microdecoration.serviceImpl.AdminServiceImpl] for bean with name 'adminServiceImpl' defined in file [C:software omcatapache-tomcat-7.0.68webappsmy-decorationWEB-INFclassescom
aarchimicrodecorationserviceImplAdminServiceImpl.class]: problem with class file or dependent class; nested exception is Java.lang.UnsupportedClassVersionError: com/naarchi/microdecoration/serviceImpl/AdminServiceImpl : Unsupported major.minor version 52.0 (unable to load class com.naarchi.microdecoration.serviceImpl.AdminServiceImpl)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1355)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:628)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:597)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1445)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:975)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:752)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5068)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5584)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1572)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1562)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.UnsupportedClassVersionError: com/naarchi/microdecoration/serviceImpl/AdminServiceImpl : Unsupported major.minor version 52.0 (unable to load class com.naarchi.microdecoration.serviceImpl.AdminServiceImpl)
at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:3122)
at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:1340)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1827)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClass
。。。。。。。。。。。。。。。。。(太多,就不弄完了)
3.解决方案,我用的事jdk1.8,果断换了1.7,然后OK了
(1).首先是安装jdk1.7
(2).配置环境变量
(3).修改eclipse里面的jre
(A).Windows->Preferences->java->Installed JREs->Add...->Standard VM("next")->第一排Directory...->找到安装位置下的文件夹,确定->apply
(B).重新更新一下server里面的tomcat("有时候换了jdk后会显示找不到jre")
Windows->server->Runtime Environm->Add->Next->Finish
4.如果以上方案没有能解决存在的问题,欢迎加好友讨论:2318645572