gpt4 book ai didi

eclipse - 基本 Spring MVC Web 应用程序导致 "ContextLoaderListener"错误

转载 作者:行者123 更新时间:2023-12-02 12:18:13 25 4
gpt4 key购买 nike

我正在尝试创建我的第一个 Spring MVC Web 应用程序。我已经下载了 Spring Tool Suite 并按照以下说明进行操作:

To setup a new project in STS: Click File -> New -> Spring Template Project -> Spring MVC Project To pull in dependencies and compile your project: Right click your new project -> Run As -> Maven install To run your project inside an application server: Right click your new project -> Run As -> Run on Server -> SpringSource tc Server If it works, you'll see a web page saying "Congratulations! You're running Spring!" (https://stackoverflow.com/a/2444805/866447)

但是当我启动服务器时,我总是收到以下错误:

Mrz 29, 2012 12:29:57 PM org.apache.catalina.startup.SetContextPropertiesRule begin
Warnung: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:undnochmal' did not find a matching property.
[TomcatWeavingInsightClassLoader@db27fb2] warning ignoring duplicate definition: jar:file:/C:/springsource/vfabric-tc-server-developer-2.6.4.RELEASE/spring-insight-instance/insight/collection-plugins/insight-collection-1.5.1.SR2.jar!/META-INF/aop.xml
[TomcatWeavingInsightClassLoader@db27fb2] warning ignoring duplicate definition: jar:file:/C:/springsource/vfabric-tc-server-developer-2.6.4.RELEASE/spring-insight-instance/insight/collection-plugins/insight-plugin-jdbc-1.5.1.SR2.jar!/META-INF/aop.xml
[TomcatWeavingInsightClassLoader@db27fb2] warning ignoring duplicate definition: jar:file:/C:/springsource/vfabric-tc-server-developer-2.6.4.RELEASE/spring-insight-instance/insight/collection-plugins/insight-collection-1.5.1.SR2.jar!/META-INF/aop-ajc.xml
[TomcatWeavingInsightClassLoader@db27fb2] warning ignoring duplicate definition: jar:file:/C:/springsource/vfabric-tc-server-developer-2.6.4.RELEASE/spring-insight-instance/insight/collection-plugins/insight-plugin-jdbc-1.5.1.SR2.jar!/META-INF/aop-ajc.xml
[TomcatWeavingInsightClassLoader@db27fb2] warning ignoring duplicate definition: jar:file:/C:/springsource/vfabric-tc-server-developer-2.6.4.RELEASE/spring-insight-instance/insight/collection-plugins/insight-plugin-tomcat-1.5.1.SR2.jar!/META-INF/aop-ajc.xml
ASPECTJ: aspectj.overweaving=true: overweaving switched ON
Mrz 29, 2012 12:29:57 PM org.apache.catalina.core.StandardContext listenerStart
Schwerwiegend: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: org/springframework/context/ConfigurableApplicationContext
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404)
at java.lang.Class.getConstructor0(Class.java:2714)
at java.lang.Class.newInstance0(Class.java:343)
at java.lang.Class.newInstance(Class.java:325)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:125)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4715)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:897)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:873)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:649)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1581)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ClassNotFoundException: org.springframework.context.ConfigurableApplicationContext
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
... 20 more

我完全困惑了...我使用了默认的 IDE、默认的 SpringMVC 模板和默认的服务器。什么问题?或者我之前必须执行一些没有写到的强制性步骤?

最佳答案

您应该包含“spring-context”

例如,此配置将引发您遇到的失败。

    <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework.version}</version>
<scope>test</scope>
</dependency>

正确版本是

    <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework.version}</version>
</dependency>

确保库已复制到 lib 目录。

关于eclipse - 基本 Spring MVC Web 应用程序导致 "ContextLoaderListener"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9923852/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com