在昨天构建的Struts2项目上测试Spring2所需要的Jar包
结果
spring-core.jar
——>依赖:spring-web.jar
——>依赖:spring-context.jar
——>依赖:spring-beans.jar
——>依赖:commons-logging.jar
开始,单加入spring-core.jar,配置web.xml
<!-- ××××××××××××××× Spring配置和监听 Start ××××××××××××××× -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/application*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- ×××××××××××××××× Spring配置和监听 End ×××××××××××××××× -->
运行——
严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
解决——
缺少org.springframework.web.*,加入spring-web.jar
运行——
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContextException
Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContextException
解决——
缺少org.springframework.context.*,加入spring-context.jar
运行——
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: org/springframework/beans/FatalBeanException
Caused by: java.lang.ClassNotFoundException: org.springframework.beans.FatalBeanException
解决——
缺少org.springframework.beans.*,加入spring-beans.jar
运行——
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
解决——缺少org.apache.commons.logging.*,加入commons-logging.jar
struts.xml加入<constant name="struts.objectFactory" value="spring" />
运行——
2010-3-3 20:53:35 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
严重: Dispatcher initialization failed
Unable to load configuration. - [unknown location]
Caused by: Cannot locate the chosen ObjectFactory implementation: spring - [unknown location]
......
2010-3-3 20:53:35 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter struts2
Unable to load configuration. - [unknown location]
......
Caused by: Unable to load configuration. - [unknown location]
......
Caused by: Cannot locate the chosen ObjectFactory implementation: spring - [unknown location]
......
解决——找不到ObjectFactory,加入struts2-spring-plugin-2.1.8.1.jar
不是说struts2整合了spring之后,创建类对象会根据spring配置文件里面的<bean>来配置吗?
这里并没有做<bean>配置,但是一样访问成功了......
惯例PS:
发现文章有错的请通知我,非常感谢!
来过的朋友请顺便踩一脚......^_^