A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

h492248322

初级黑马

  • 黑马币:11

  • 帖子:8

  • 精华:0

© h492248322 初级黑马   /  2018-7-10 13:38  /  1162 人查看  /  2 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

HTTP ERROR 500
Problem accessing /user_registPage.action. Reason:

    Unable to instantiate Action, userAction,  defined for 'user_registPage' in namespace '/'Error creating bean with name 'userAction' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'userService' while setting bean property 'userService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'userDao' while setting bean property 'userDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/orm/hibernate3/SpringSessionContext
Caused by:
Unable to instantiate Action, userAction,  defined for 'user_registPage' in namespace '/'Error creating bean with name 'userAction' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'userService' while setting bean property 'userService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'userDao' while setting bean property 'userDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/orm/hibernate3/SpringSessionContext

2 个回复

倒序浏览
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
        xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"
        xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jpa="http://www.springframework.org/schema/data/jpa"
        xmlns:aop="http://www.springframework.org/schema/aop"
        xsi:schemaLocation="
                http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
                http://www.springframework.org/schema/context http://www.springframework.org/s ... ing-context-4.0.xsd
                http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsd
                http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
                http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
                http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
                http://www.springframework.org/schema/aop
                http://www.springframework.org/schema/aop/spring-aop-4.3.xsd"
        default-lazy-init="true">
        <!--加载属性文件 -->
        <context:property-placeholder location="classpath:db.properties" />
        <!--配置数据源 -->
        <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
                <property name="driverClass" value="${jdbc.driverClass}"></property>
                <property name="jdbcUrl" value="${jdbc.jdbcUrl}"></property>
                <property name="user" value="${jdbc.user}"></property>
                <property name="password" value="${jdbc.password}"></property>
        </bean>
       
                <!--配置Hibernate相关信息  -->
         <!--配置SessionFactory -->
        <bean id="sessionFactory"
                class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
                <!--注入连接池  -->
                <property name="dataSource" ref="dataSource"></property>
                <!--配置Hibernate其他属性  -->
                <property name="hibernateProperties">
                        <props>
                        <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
                        <prop key="hibernate.show.sql">true</prop>
                        <prop key="hibernate.format_sql">true</prop>
                        <prop key="hibernate.connection.autocommit">false</prop>
                        </props>
                </property>
                <!--配置Hibernate的映射文件  -->
                <property name="mappingResources">
                <list>
                        <value>cn/jeff/shop/user/vo/User.hbm.xml</value>
                </list>
        </property>
        </bean>

        <!--配置事务管理器 -->
        <bean id="transactionManager"
                class="org.springframework.orm.hibernate3.HibernateTransactionManager">
                <property name="sessionFactory" ref="sessionFactory"/>
        </bean>

        <!--xml方式管理事务 -->
        <!--配置通知:具体增强逻辑 -->
        <!-- <tx:advice id="txAdvice">
                <tx:attributes>
                        匹配业务类中方法名称
                        <tx:method name="save*" />
                        <tx:method name="update*" />
                        <tx:method name="delete*" />
                        <tx:method name="find*" read-only="true" />
                        <tx:method name="*" />
                </tx:attributes>
        </tx:advice> -->

        <!--配置aop -->
        <!-- <aop:config>
                配置切点:具体哪些方法要增强
                <aop:pointcut expression="execution(* cn.itcast.service.*.*(..))"
                        id="cut" />
                配置切面 :将增强逻辑作用到切点(通知+切入点)
                <aop:advisor advice-ref="txAdvice" pointcut-ref="cut" />
        </aop:config> -->

        <!--注解方式管理事务 -->
        <!--1、开启注解驱动 2、在service类上或者方法上使用注解 @Transactional -->
         <tx:annotation-driven transaction-manager="transactionManager"/>

        <!--首页访问的action对象 -->
        <bean id="indexAction" class="cn.jeff.shop.index.action.IndexAction"
                scope="prototype">
        </bean>

        <!--Dao的配置=============================  -->
        <bean id="userDao" class="cn.jeff.shop.user.dao.UserDao">
                <property name="sessionFactory" ref="sessionFactory"/>
        </bean>
       
        <!--Service的配置===========================  -->
        <bean id="userService" class="cn.jeff.shop.user.service.UserService">
                <property name="userDao" ref="userDao"/>
        </bean>
       
        <!--用户模块的Action  -->
        <bean id="userAction" class="cn.jeff.shop.user.action.UserAction"
                scope="prototype">
                <!--注入Service  -->
                <property name="userService" ref="userService"/>
        </bean>
</beans>
回复 使用道具 举报
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
        <constant name="struts.devMode" value="false"></constant>
        <package name="shop"  extends="struts-default" namespace="/">
                <!--配置首页访问的Action  -->
                <action name="index" class="indexAction">
                                <result name="index">/WEB-INF/jsp/index.jsp</result>
                </action>
               
                <!--配置用户模块Action  -->
                <action name="user_*" class="userAction" method="{1}">
                <result name="registPage">/WEB-INF/jsp/regist.jsp</result>
                <result name="input">/WEB-INF/jsp/regist.jsp</result>
                </action>
        </package>

</struts>
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马