applicationContext.xml
<?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: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.0.xsd
   http://www.springframework.org/schema/tx            
   http://www.springframework.org/schema/tx/spring-tx-2.5.xsd            
   http://www.springframework.org/schema/aop            
   http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
 
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver">
</property>
<property name="url" value="jdbc:mysql://localhost:3306/photosystem">
</property>
<property name="username" value="root"></property>
<property name="password" value="root"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<!-- <value>com.sun.java.entity/Photo.hbm.xml</value>
<value>com.sun.java.entity/Photoword.hbm.xml</value>
<value>com.sun.java.entity/Kind.hbm.xml</value> -->
<value>com/sun/java/entity/User.hbm.xml</value>
<!-- <value>com.sun.java.entity/Album.hbm.xml</value> -->
</list>
</property>
</bean>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
 
 <bean id="userDao" class="com.sun.java.dao.UserDao">
  <property name="hibernateTemplate" ref="hibernateTemplate"></property>
 </bean>
 <bean id="userService" class="com.sun.java.service.UserService">
  <property name="userDao" ref="userDao"></property>
 </bean>
 
<bean id="register" class="com.sun.java.action.UserAction">
<property name="userService" ref="userService"></property>
</bean>

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

<!--  配置事务传播特性 -->
<tx:advice id="TestAdvice" transaction-manager="transactionManager">
    <tx:attributes>
      <tx:method name="save*" propagation="REQUIRED"/>
      <tx:method name="del*" propagation="REQUIRED"/>
      <tx:method name="update*" propagation="REQUIRED"/>
      <tx:method name="add*" propagation="REQUIRED"/>
      <tx:method name="find*" propagation="REQUIRED"/>
      <tx:method name="get*" propagation="REQUIRED"/>
      <tx:method name="apply*" propagation="REQUIRED"/>
    </tx:attributes>
</tx:advice>

<!--  配置参与事务的类 -->
<aop:config>
<aop:pointcut id="allTestServiceMethod" expression="execution(* com.sun.java.service.*.*(..))"/>
<aop:advisor pointcut-ref="allTestServiceMethod" advice-ref="TestAdvice" />
</aop:config>


</beans>
后台异常:警告: Ignored XML validation warning
org.xml.sax.SAXParseException; lineNumber: 66; columnNumber: 70; schema_reference.4: 无法读取方案文档 'http://www.springframework.org/schema/tx/spring-tx-2.5.xsd', 原因为 1) 无法找到文档; 2) 无法读取文档; 3) 文档的根元素不是 <xsd:schema>。
……
……
Caused by: java.net.SocketException: Software caused connection abort: recv failed
……
……
严重: Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 66 in XML document from class path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 66; columnNumber: 70; cvc-complex-type.2.4.c: 通配符的匹配很全面, 但无法找到元素 'tx:advice' 的声明。

解决方案 »

  1.   

     lineNumber: 66; columnNumber: 70; schema_reference.4
    看看这一行写的对不对。
    还有<tx:advice id="TestAdvice" transaction-manager="transactionManager">红色部分首字母小写,注意下规范。
      

  2.   

    <tx:method name="save*" propagation="REQUIRED"/>
    <tx:method name="del*" propagation="REQUIRED"/>
    <tx:method name="update*" propagation="REQUIRED"/>
    <tx:method name="add*" propagation="REQUIRED"/>
    <tx:method name="find*" propagation="REQUIRED"/>
    <tx:method name="get*" propagation="REQUIRED"/>
    <tx:method name="apply*" propagation="REQUIRED"/>
    你这段有问题吧,你仔细看看
      

  3.   

    beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    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.0.xsd
    http://www.springframework.org/schema/tx   
    http://www.springframework.org/schema/tx/spring-tx-2.5.xsd   
    http://www.springframework.org/schema/aop   
    http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
    还有,如果你按住ctrl键去试试,可能你的文件没得,你需要手动导入
      

  4.   

    楼主你的声明你beans标签是3.0的,tx和aop的都是2.5改统一了应该就好了
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/tx   
    http://www.springframework.org/schema/tx/spring-tx-2.5.xsd   
    http://www.springframework.org/schema/aop   
    http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
    要根据你spring的版本来