Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/395.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 是否可以将SpringBeans xml文件移到WAR之外?_Java_Spring_War_Applicationcontext - Fatal编程技术网

Java 是否可以将SpringBeans xml文件移到WAR之外?

Java 是否可以将SpringBeans xml文件移到WAR之外?,java,spring,war,applicationcontext,Java,Spring,War,Applicationcontext,我试图通过调整web.xml将Springbeans的位置移到WAR之外。My web.xml包含以下内容: <context-param> <param-name>contextConfigLocation</param-name> <param-value>WEB-INF/intu-1.0.0-beans.xml</param-value> </context-param> <liste

我试图通过调整web.xml将Springbeans的位置移到WAR之外。My web.xml包含以下内容:

  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>WEB-INF/intu-1.0.0-beans.xml</param-value>
  </context-param>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

您可以使用带有spring导入标记的
文件:
路径:

<import resource="file:/home/user/spring-beans.xml"/>


在您的
rts application context.xml

中,当我这样做时,它可能会加载文件,但它仍然(也)尝试从WAR加载intu-1.0.0-beans.xml。我已经在我的代码中搜索了所有可能的方法,但是我找不到任何可能发生这种情况的地方。我得到的错误是:从ServletContext资源[/WEB-INF/intu-1.0.0-beans.XML]解析XML文档;嵌套异常为java.io.FileNotFoundException:无法打开ServletContext资源[/WEB-INF/intu-1.0.0-beans.xml]您能否发布完整的错误堆栈,这将提示如何从堆栈加载intu..xml文件错误来自WEB.xml配置。请检查是否部署了正确的war(使用带有注释配置的web.xml)。验证的一种方法是向web.xml添加一个错误,并确认服务器显示了这一点。我将尝试一下,稍后再返回。顺便说一下,我在使用eclipse.hmm时,我将它要查找的文件放在了C:\tomcat7\webapps\IntuRTS\WEB-INF中,它仍然不断地给出相同的错误。
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>WEB-INF/rts-application-context.xml</param-value>
  </context-param>
  <!--<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>WEB-INF/intu-1.0.0-beans.xml</param-value>
  </context-param>-->
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
jun 02, 2015 3:55:57 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
jun 02, 2015 3:55:57 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/intu-1.0.0-beans.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/intu-1.0.0-beans.xml]
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:349)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
    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.deployDirectory(HostConfig.java:1120)
    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1678)
    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:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)
Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/intu-1.0.0-beans.xml]
    at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:117)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
    ... 26 more
<import resource="file:/home/user/spring-beans.xml"/>