spring3.2.2+struts2.3.14  出现这些问题:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/tx]
Offending resource: class path resource [beans.xml]

java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
请问大家这是怎么回事?SpringStrutsSSH整合

解决方案 »

  1.   

    xml配置文件 有错误,
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd 
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd"
    default-lazy-init="true">
      

  2.   

    是加上“default-lazy-init="true"” ??加上后还是有错误啊
      

  3.   

    看下这个少包了http://blog.csdn.net/brucezhang0/article/details/7842492
      

  4.   

    这是spring的配置文件:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans.xsd
                http://www.springframework.org/schema/context
               http://www.springframework.org/schema/context/spring-context.xsd
                http://www.springframework.org/schema/tx
          http://www.springframework.org/schema/tx/spring-tx.xsd
               http://www.springframework.org/schema/aop
               http://www.springframework.org/schema/aop/spring-aop.xsd">
    <context:annotation-config />
    <context:component-scan base-package="com.wtu" />
    <!-- <aop:aspectj-autoproxy /> -->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mysql://localhost/spring" />
    <property name="username" value="root" />
    <property name="password" value="root" />
    </bean> <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />   <property name="packagesToScan">  
    <list>
    <value>com.wtu.model</value>
    </list>
    </property> <property name="hibernateProperties">  
    <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
    <prop key="hibernate.show_sql">true</prop>
    </props> </property>
    </bean>
    <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
    <property name="sessionFactory" ref="sessionFactory" />
    </bean> <bean id="txManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">  <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    <tx:annotation-driven transaction-manager="txManager" />
    <aop:config>
    <aop:pointcut expression="execution(public * com.wtu.service.impl..*.*(..))"
    id="bussinessService" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="bussinessService" />
    </aop:config>
    <tx:advice id="txAdvice" transaction-manager="txManager">
    <tx:attributes>
    <tx:method name="exists" read-only="true" />
    <tx:method name="add*" propagation="REQUIRED" />
    </tx:attributes>
    </tx:advice></beans>下面是struts的配置文件:
    <?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>
        <package name="registration" extends="struts-default">
            <action name="user" class="com.wtu.action.UserAction">
                <result name="success">/registerSuccess.jsp </result>
                 <result name="fail">/registerFail.jsp </result>
            </action>
        </package>
    </struts>
      

  5.   

    刚整合了一份儿,http://www.liutime.com/java_circlescontentinfo/id=706
    里面有下载地址
      

  6.   


    请看我的博客开源项目,是基于spring,security开发的http://blog.csdn.net/shadowsick