ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the cont

来源:互联网 发布:linux编程获取cpu温度 编辑:程序博客网 时间:2024/06/08 04:52

项目部署报错:

ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext: startup date 

这句话的意思是spring在加载前就已经被关闭了。

网上查了半天,说是找不到applicationContext.xml文件,或者没有在web.xml里面配置监听的,

我的情况比较特殊,已解决,原因如下:

在给spring加事务的时候:少些了红线的最后一个。。。

<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<span style="color:#ff0000;">xmlns:aop="http://www.springframework.org/schema/aop"</span>xmlns:tx="http://www.springframework.org/schema/tx"    xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.0.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-2.0.xsd<span style="color:#ff0000;">http://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-2.0.xsd</span>">      <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"destroy-method="close"><property name="driverClassName" value="${jdbc.driverClassName}"></property><property name="url" value="${jdbc.url}"></property><property name="username" value="${jdbc.username}"></property><property name="password" value="${jdbc.password}"></property><!-- 连接池启动时的初始值 --><property name="testOnBorrow" value="true" /><property name="testWhileIdle" value="true" /><property name="testOnReturn" value="true" /><property name="validationQuery" value="select 1 from dual" /><property name="validationQueryTimeout" value="1" /><property name="numTestsPerEvictionRun" value="50" /><property name="initialSize" value="10" /><!-- 连接池的最大值 --><property name="maxActive" value="100" /><!-- 最大空闲值。当经过一个高峰时间后,连接池可以慢慢将已经用不到的连接慢慢释放一部分,一直减少到maxIdle为止 --><property name="maxIdle" value="50" /><!-- 最小空闲值。当空闲的连接数少于阀值时,连接池就会预申请一些连接,以免洪峰来时来不及申请 --><property name="minIdle" value="10" /><!-- #运行判断连接超时任务的时间间隔,单位为毫秒,默认为-1,即不执行任务。 --><property name="timeBetweenEvictionRunsMillis" value="30000" /><!-- #连接的超时时间,默认为半小时。 --><property name="minEvictableIdleTimeMillis" value="3600000" /><!-- 超过removeAbandonedTimeout时间后,是否进 行没用连接(废弃)的回收 (timeout默认300s) --><property name="removeAbandoned" value="true" /><!-- 标记当连接被回收时是否打印程序的stack traces日志 --><property name="logAbandoned" value="true" /></bean>         <!-- 事务控制 --><bean id="txManager"class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource" /></bean> <tx:advice id="txAdvice" transaction-manager="txManager"><tx:attributes><!-- 传播行为 --><tx:method name="save*" propagation="REQUIRED" /><tx:method name="insert*" propagation="REQUIRED" /><tx:method name="add*" propagation="REQUIRED" /><tx:method name="create*" propagation="REQUIRED" /><tx:method name="delete*" propagation="REQUIRED" /><tx:method name="update*" propagation="REQUIRED" /><tx:method name="find*" propagation="SUPPORTS" read-only="true" /><tx:method name="select*" propagation="SUPPORTS" read-only="true" /><tx:method name="get*" propagation="SUPPORTS" read-only="true" /></tx:attributes></tx:advice> <aop:config><aop:pointcut id="methodPointcut" expression="execution(* com.anbang.shop.service.*.*(..))"/><aop:advisor pointcut-ref="methodPointcut" advice-ref="txAdvice"/></aop:config>
加上事务之后,在删除和新增的一个操作里面是原子性的。

0 2
原创粉丝点击