【发布时间】:2014-06-20 09:48:50
【问题描述】:
我是春季新手
我尝试使用 cargo 在 tomcat 上部署我的 war 文件,它抱怨在目录中找不到 applicationContext.xml。
我进一步查看了它应该去哪里并添加了一个空白 xml 文件 applicationContext.xml 以查看它是否有效,但随后它抱怨了一些事情
[INFO] [talledLocalContainer] SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
[INFO] [talledLocalContainer] org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 1 in XML document from class path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature end of file.
我不确定我为什么需要applicationContext.xml,如果我真的需要它,我应该在里面放什么?
我尽可能多地使用@annotations,并且我的单元测试也正确通过,意思是,我看到我的 bean 确实连接正确
前辈,请帮忙
谢谢
更新
src/main/webapp/WEB-INF/web.xml
<xml>
</xml>
src/main/resources/applicationContext.xml
<beans></beans>
【问题讨论】:
-
当你说货物时,你的意思是cargo.codehaus.org/Deploying+to+a+running+container?您还可以展示您的 Java Config 和 web.xml 吗?
-
web.xml 怎么样(或者您使用的是 Servlet 3 初始化程序)?
-
我的错,我有
web.xml而不是beans.xml。我没有beans.xml -
好的,您是否有机会使用
WebApplicationInitializer或WebMvcConfigurerAdapter?如果是这样,实现/扩展这些的类的内容是什么?
标签: java xml spring spring-mvc annotations