我整合ssh框架整合完后启动容器 在控制台就报了这样一个错:
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 47 in XML document from class path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'tx:advice'.
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'tx:advice'.我的applicationContext.xml事务是这样配置的:
<!-- 事务管理器,用于将目标对象与事务整合 -->
<bean id="htm"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 通知 -->
<tx:advice id="advice" transaction-manager="htm">
<!-- 为业务方法指定传播行为:即什么时候创建事务 -->
<tx:attributes>
<!-- name:方法名,是需要指定事务传播行为的方法(如果事务存在,则使用现有事务,否则使用新事务) -->
<!-- <tx:method name="insert*" propagation="REQUIRED" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />-->
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="query*" propagation="REQUIRED"
read-only="true" />
</tx:attributes>
</tx:advice>
<!-- 配置pointcut,指明哪些方法需要织入事务 -->
<aop:config>
<aop:pointcut id="pc"
expression="execution(public * com.qhit.service.*.*(..))" />
<aop:advisor advice-ref="advice" pointcut-ref="pc" />
</aop:config>
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 47 in XML document from class path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'tx:advice'.
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'tx:advice'.我的applicationContext.xml事务是这样配置的:
<!-- 事务管理器,用于将目标对象与事务整合 -->
<bean id="htm"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 通知 -->
<tx:advice id="advice" transaction-manager="htm">
<!-- 为业务方法指定传播行为:即什么时候创建事务 -->
<tx:attributes>
<!-- name:方法名,是需要指定事务传播行为的方法(如果事务存在,则使用现有事务,否则使用新事务) -->
<!-- <tx:method name="insert*" propagation="REQUIRED" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />-->
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="query*" propagation="REQUIRED"
read-only="true" />
</tx:attributes>
</tx:advice>
<!-- 配置pointcut,指明哪些方法需要织入事务 -->
<aop:config>
<aop:pointcut id="pc"
expression="execution(public * com.qhit.service.*.*(..))" />
<aop:advisor advice-ref="advice" pointcut-ref="pc" />
</aop:config>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">头上写那些东西了吗?
我写的是这个:
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
你少定义了schema,4楼说得对
不识别tx:advice你换成2.5.xsd试试
报了一个
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate NamespaceHandler for namespace [http://www.springframework.org/schema/tx]
Offending resource: class path resource [applicationContext.xml]
打开http://www.springframework.org/schema/tx看一下能访问不?
好像是jar包版本问题,我的和你的差不多,这样解决了
我估计你要加2,0试下这个
你没加2.5别用2.5的头文件。都用2.0的