我是春天的天真用户。我刚刚开始学习它。我想通过理解例子学习春天。所以我尝试从链接https://github.com/SpringSource/spring-petclinic安装弹簧的petclicnic示例应用程序。当我尝试运行mvn install命令时出现以下错误 java.lang.NoClassDefFoundError:org / springframework / beans / factory / NoUniqueBeanDe finitionException。我尝试使用https://jira.springsource.org/browse/SPR-10218中提供的信息解决此问题。我添加了所有依赖项。现在我收到以下错误。请帮忙
ERROR ContextLoader - Context initialization failed
java.lang.NoClassDefFoundError: org/springframework/asm/ClassVisitor
at org.springframework.beans.factory.support.Abstract AutowireCapableBean
Factory.<init>(AbstractAutowireCapableBeanFactory. java:121) ~[spring-beans-3.1.4
.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.beans.factory.support.Abstract AutowireCapableBean
Factory.<init>(AbstractAutowireCapableBeanFactory. java:168) ~[spring-beans-3.1.4
.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.
<init>(DefaultListableBeanFactory.java:163) ~[spring-beans-3.1.4.RELEASE.jar:3.1
.4.RELEASE]
at org.springframework.context.support.AbstractRefres hableApplicationCon
text.createBeanFactory(AbstractRefreshableApplicat ionContext.java:194) ~[spring-
context-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.context.support.AbstractRefres hableApplicationCon
text.refreshBeanFactory(AbstractRefreshableApplica tionContext.java:127) ~[spring
-context-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.context.support.AbstractApplic ationContext.obtain
FreshBeanFactory(AbstractApplicationContext.java:5 37) ~[spring-context-3.2.2.REL
EASE.jar:3.2.2.RELEASE]
at org.springframework.context.support.AbstractApplic ationContext.refres
h(AbstractApplicationContext.java:451) ~[spring-context-3.2.2.RELEASE.jar:3.2.2.
RELEASE]
at org.springframework.web.context.ContextLoader.conf igureAndRefreshWebA
pplicationContext(ContextLoader.java:389) ~[spring-web-3.2.2.RELEASE.jar:3.2.2.R
ELEASE]
at org.springframework.web.context.ContextLoader.init WebApplicationConte
xt(ContextLoader.java:294) ~[spring-web-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.web.context.ContextLoaderListe ner.contextInitiali
zed(ContextLoaderListener.java:112) [spring-web-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.apache.catalina.core.StandardContext.listenerS tart(StandardContex
t.java:4791) [tomcat-embed-core-7.0.30.jar:7.0.30]
at org.apache.catalina.core.StandardContext.startInte rnal(StandardContex
t.java:5285) [tomcat-embed-core-7.0.30.jar:7.0.30]
at org.apache.catalina.util.LifecycleBase.start(Lifec ycleBase.java:150)
[tomcat-embed-core-7.0.30.jar:7.0.30]
at org.apache.catalina.core.ContainerBase$StartChild. call(ContainerBase.
java:1559) [tomcat-embed-core-7.0.30.jar:7.0.30]
at org.apache.catalina.core.ContainerBase$StartChild. call(ContainerBase.
java:1549) [tomcat-embed-core-7.0.30.jar:7.0.30]
at java.util.concurrent.FutureTask$Sync.innerRun(Futu reTask.java:303) [n
a:1.6.0_20]
at java.util.concurrent.FutureTask.run(FutureTask.jav a:138) [na:1.6.0_20
]
at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(ThreadPoolExec
utor.java:886) [na:1.6.0_20]
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor
.java:908) [na:1.6.0_20]
at java.lang.Thread.run(Thread.java:619) [na:1.6.0_20]
Caused by: java.lang.ClassNotFoundException: org.springframework.asm.ClassVisito
r
at org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoa
der.java:1714) ~[tomcat-embed-core-7.0.30.jar:7.0.30]
at org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoa
der.java:1559) ~[tomcat-embed-core-7.0.30.jar:7.0.30]
... 20 common frames omitted
INFO XmlWebApplicationContext - Closing Root WebApplicationContext: startup dat
e [Wed Mar 27 11:31:56 CDT 2013]; root of context hierarchy
WARN XmlWebApplicationContext - Exception thrown from ApplicationListener handl
ing ContextClosedEvent
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - c
all 'refresh' before multicasting events via the context: Root WebApplicationCon
text: startup date [Wed Mar 27 11:31:56 CDT 2013]; root of context hierarchy
at org.springframework.context.support.AbstractApplic ationContext.getApp
licationEventMulticaster(AbstractApplicationContex t.java:347) [spring-context-3.
2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.context.support.AbstractApplic ationContext.publis
hEvent(AbstractApplicationContext.java:334) [spring-context-3.2.2.RELEASE.jar:3.
2.2.RELEASE]
at org.springframework.context.support.AbstractApplic ationContext.doClos
e(AbstractApplicationContext.java:1049) [spring-context-3.2.2.RELEASE.jar:3.2.2.
RELEASE]
at org.springframework.context.support.AbstractApplic ationContext.close(
AbstractApplicationContext.java:1010) [spring-context-3.2.2.RELEASE.jar:3.2.2.RE
LEASE]
at org.springframework.web.context.ContextLoader.clos eWebApplicationCont
ext(ContextLoader.java:558) [spring-web-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.web.context.ContextLoaderListe ner.contextDestroye
d(ContextLoaderListener.java:143) [spring-web-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.apache.catalina.core.StandardContext.listenerS top(StandardContext
.java:4831) [tomcat-embed-core-7.0.30.jar:7.0.30]
at org.apache.catalina.core.StandardContext.stopInter nal(StandardContext
.java:5478) [tomcat-embed-core-7.0.30.jar:7.0.30]
at org.apache.catalina.util.LifecycleBase.stop(Lifecy cleBase.java:232) [
tomcat-embed-core-7.0.30.jar:7.0.30]
at org.apache.catalina.util.LifecycleBase.start(Lifec ycleBase.java:160)
[tomcat-embed-core-7.0.30.jar:7.0.30]
at org.apache.catalina.core.ContainerBase$StartChild. call(ContainerBase.
java:1559) [tomcat-embed-core-7.0.30.jar:7.0.30]
at org.apache.catalina.core.ContainerBase$StartChild. call(ContainerBase.
java:1549) [tomcat-embed-core-7.0.30.jar:7.0.30]
at java.util.concurrent.FutureTask$Sync.innerRun(Futu reTask.java:303) [n
a:1.6.0_20]
at java.util.concurrent.FutureTask.run(FutureTask.jav a:138) [na:1.6.0_20
]
at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(ThreadPoolExec
utor.java:886) [na:1.6.0_20]
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor
.java:908) [na:1.6.0_20]
at java.lang.Thread.run(Thread.java:619) [na:1.6.0_20]
WARN XmlWebApplicationContext - Exception thrown from LifecycleProcessor on con
text close
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refr
esh' before invoking lifecycle methods via the context: Root WebApplicationConte
xt: startup date [Wed Mar 27 11:31:56 CDT 2013]; root of context hierarchy
at org.springframework.context.support.AbstractApplic ationContext.getLif
ecycleProcessor(AbstractApplicationContext.java:36 0) [spring-context-3.2.2.RELEA
SE.jar:3.2.2.RELEASE]
at org.springframework.context.support.AbstractApplic ationContext.doClos
e(AbstractApplicationContext.java:1057) [spring-context-3.2.2.RELEASE.jar:3.2.2.
RELEASE]
at org.springframework.context.support.AbstractApplic ationContext.close(
AbstractApplicationContext.java:1010) [spring-context-3.2.2.RELEASE.jar:3.2.2.RE
LEASE]
at org.springframework.web.context.ContextLoader.clos eWebApplicationCont
ext(ContextLoader.java:558) [spring-web-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.web.context.ContextLoaderListe ner.contextDestroye
d(ContextLoaderListener.java:143) [spring-web-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.apache.catalina.core.StandardContext.listenerS top(StandardContext
.java:4831) [tomcat-embed-core-7.0.30.jar:7.0.30]
at org.apache.catalina.core.StandardContext.stopInter nal(StandardContext
.java:5478) [tomcat-embed-core-7.0.30.jar:7.0.30]
at org.apache.catalina.util.LifecycleBase.stop(Lifecy cleBase.java:232) [
tomcat-embed-core-7.0.30.jar:7.0.30]
at org.apache.catalina.util.LifecycleBase.start(Lifec ycleBase.java:160)
[tomcat-embed-core-7.0.30.jar:7.0.30]
at org.apache.catalina.core.ContainerBase$StartChild. call(ContainerBase.
java:1559) [tomcat-embed-core-7.0.30.jar:7.0.30]
at org.apache.catalina.core.ContainerBase$StartChild. call(ContainerBase.
java:1549) [tomcat-embed-core-7.0.30.jar:7.0.30]
at java.util.concurrent.FutureTask$Sync.innerRun(Futu reTask.java:303) [n
a:1.6.0_20]
at java.util.concurrent.FutureTask.run(FutureTask.jav a:138) [na:1.6.0_20
]
at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(ThreadPoolExec
utor.java:886) [na:1.6.0_20]
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor
.java:908) [na:1.6.0_20]
at java.lang.Thread.run(Thread.java:619) [na:1.6.0_20]
答案 0 :(得分:0)
将asm.jar添加到类路径中。由于spring内部使用了许多第三方库,因此您可能还会获得其他classnotfound异常。我通常去jarfinder.com提供类名,然后下载该类的jar并放入类路径。
答案 1 :(得分:0)
例外清楚地说
java.lang.NoClassDefFoundError: org/springframework/asm/ClassVisitor
这意味着您没有在类路径中包含spring asm库。
在类路径中包含spring-asm.jar文件以解决问题。