2017-06-28 63 views
0

我使用Spring 4.3.8.RELEASE与Hibernate 5.1.5.Final。我想在另一个事务完成后执行一个方法。该交易是低于WNY我收到 “java.lang.IllegalStateException:没有TransactionalEventListener标注”?

@Service("organizationService") 
@Transactional 
public class OrganizationServiceImpl implements OrganizationService, ApplicationEventPublisherAware 
{ 

    private ApplicationEventPublisher publisher; 

    @Override 
    public void setApplicationEventPublisher(ApplicationEventPublisher publisher) 
    { 
     this.publisher = publisher; 
    } 

    @Override 
    public void save(Organization organization) 
    { 
    ... 

     // sync data with ThirdParty but only if something has definitelychanged on the SB 
     // side, in which case we want to send ThirdParty an update. 
     if (!hasSameAttributes) 
     { 
      publisher.publishEvent(new ThirdPartyOrganizationEvent(organization.getId())); 
     } // if 
    } // save 

因此,这里定义的是,我想上述交易完成后执行的方法...

@Service 
public class ThirdPartyAPIServiceImpl implements ThirdPartyAPIService 
{ 

    @Override 
    @TransactionalEventListener 
    public boolean updateOrg(final ThirdPartyOrganizationEvent thirdPartyOrgEvent) 
    { 
     ... 
    } 

但是,当我打开我的应用程序方面,我得到这个错误

Caused by: java.lang.IllegalStateException: No TransactionalEventListener annotation found on method: public abstract boolean org.mainco.subco.myproject.service.ThirdPartyAPIService.updateOrg(org.mainco.subco.myproject.domain.ThirdPartyOrganizationEvent) 
    at org.springframework.transaction.event.ApplicationListenerMethodTransactionalAdapter.<init>(ApplicationListenerMethodTransactionalAdapter.java:55) 
    at org.springframework.transaction.event.TransactionalEventListenerFactory.createApplicationListener(TransactionalEventListenerFactory.java:55) 
    at org.springframework.context.event.EventListenerMethodProcessor.processBean(EventListenerMethodProcessor.java:159) 
    at org.springframework.context.event.EventListenerMethodProcessor.afterSingletonsInstantiated(EventListenerMethodProcessor.java:104) 
    ... 34 more 

Wbat做我需要做的就是这个配置是否正确?

回答

0

定义@TransactionalEventListener对接口的方法而不是方法实现接口上为我工作。

相关问题