求助大佬,SSH整合发生java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
三大框架整合发生java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener。
调查了好久不知道哪儿出了问题。。。
具体代码如下:
applicationContext.xml |
前略... <!-- 链接池 --> <bean name="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="${jdbc.driver}" /> <property name="jdbcUrl" value="${jdbc.url}" /> <property name="user" value="${jdbc.user}" /> <property name="password" value="${jdbc.password}" /> <property name="initialPoolSize" value="${jdbc.initPoolSize}" /> <property name="maxPoolSize" value="${jdbc.maxPoolSize}" /> </bean> <!--配置sessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="configLocation" value="classpath:hibernate.cfg.xml" /> </bean> <bean id="employeeDao" class="com.hbsi.dao.imp.EmployeeDaoImp"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean id="employeeService" class="com.hbsi.service.imp.EmployeeServiceImp"> <property name="employeeDao" ref="employeeDao"></property> </bean> <bean id="employeeAction" class="com.hbsi.action.EmployeeAction"> <property name="employeeService" ref="employeeService" /> </bean> <!-- 1,配置hibernate的事务管理器 --> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <!-- 2,配置事务属性 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="get*" read-only="true" /> <tx:method name="*" /> </tx:attributes> </tx:advice> <!-- 3,配置事务切入点,再把事务属性和事务切入点关联起来 --> <aop:config> <aop:pointcut expression="execution(* com.hbsi.service.imp.*.*(..))" id="txPointcut" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut" /> </aop:config> </beans> |
hibernate.cfg.xml |
<hibernate-configuration> <session-factory> <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property> <property name="hibernate.show_sql">true</property> <property name="hibernate.format_sql">true</property> <property name="hibernate.hbm2ddl.auto">update</property> <mapping resource="com/hbsi/dojo/Employee.hbm.xml" /> <mapping resource="com/hbsi/dojo/Department.hbm.xml" /> </session-factory> </hibernate-configuration> |
struts.xml |
<struts> <constant name="struts.enable.DynamicMethodInvocation" value="false" /> <constant name="struts.devMode" value="true" /> <package name="employeePackage" namespace="/" extends="struts-portlet-default"> <action name="emp-*" class="employeeAction" method="{1}"> <result name="list">/WEB-INF/views/emp-list.jsp</result> </action> </package> </struts> |
web.xml |
<!-- Spring 配置 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- Struts2 配置 --> <filter> <filter-name>filter</filter-name> <!-- org.apache.struts2.dispatcher.FilterDispatcher --> <!-- org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter --> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> <init-param> <param-name>config</param-name> <param-value>struts-default.xml,/struts.xml,../../resources/struts.xml</param-value> </init-param> </filter> <filter-mapping> <filter-name>filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app> |
引用的jar包:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嗯嗯。这个问题已经解决,确实缺少了jar包。。谢谢
错误是找不到监听器类,你看是不是所有包都加到java 环境中,或者看有没有这个包 org.springframework.web-3.1.4.RELEASE.jar: