我有一個分開的Spring Maven項目,myapp.web僅包含JSP和靜態文件,而myapp.core包含應用上下文XML和控制器。Spring Maven項目拆分,Eclipse中的部署問題
myapp.core
- 的src /主/資源/ context.xml中
- 的src /主/資源/ MVC-context.xml中
myapp.web
- src/main/webapp/WEB-INF/web。 XML
web.xml中包含根上下文配置和servlet配置
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:/context.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
...
<servlet>
<servlet-name>servlet0</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:/mvc-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>servlet0</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
我也有OpenSessionInViewFilter
配置
<filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
<init-param>
<param-name>flushMode</param-name>
<param-value>AUTO</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
現在,生成從myapp.web戰爭和Tomcat的滴手動工作正常。 但是,當通過「Run On Server」從Eclipse運行時,OpenSessionInViewFilter
沒有看到在context.xml中配置的sessionFactory
我嘗試修復項目的構建路徑,但它不會運行。
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'sessionFactory' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:529)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1094)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:276)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1079)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.lookupSessionFactory(OpenSessionInViewFilter.java:242)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.lookupSessionFactory(OpenSessionInViewFilter.java:227)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:171)
現在我知道這是一個的Eclipse/M2E-WTP配置問題,因爲它的工作通過手動部署,但我已經無法修復它。按照通常建議的方式與項目的構建路徑一起玩,但沒有成功。
感謝
謝謝,但找到了上下文,因爲它沒有顯示任何'FileNotFoundException'。問題是'OpenSessionInViewFilter'沒有看到'context.xml'中的'sessionFactory'。 – isah