gpt4 book ai didi

java - 如何在 web.xml 中添加应用程序上下文

转载 作者:行者123 更新时间:2023-12-03 20:26:14 24 4
gpt4 key购买 nike

如何将我的测试资源文件夹中的 applicationcontext.xml 添加到 web.xml。我试过了

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/test/resources/com/reg/applicationcontext.xml</param-value>
</context-param>

<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>

我运行 mvn war:war 命令并在 apache 中部署 war 文件。但它显示错误。

Mar 12, 2013 11:31:07 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Mar 12, 2013 11:31:07 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/myapp] startup failed due to previous errors

谁能帮帮我?谢谢

本地主机。

Mar 12, 2013 11:19:57 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Skipped installing application listeners due to previous error(s)
Mar 12, 2013 11:31:07 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1713)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1558)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:527)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:509)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:137)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4733)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
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)

Mar 12, 2013 11:31:07 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Skipped installing application listeners due to previous error(s)

最佳答案

您将 applicationContext.xml 放在测试目录中?那是一个巨大的错误。因为你使用 mvn,你应该把它放在 main->resource 目录中,因为当你使用 mvn war:war 时,它不会收集测试目录中的文件。然后放到web.xml下面

 <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:**the sub dir in you resource which the config xml is in** /applicationContext.xml
</param-value>
</context-param>

关于java - 如何在 web.xml 中添加应用程序上下文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15354480/

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