我有一个分开的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