2014-07-08 3 views
0

내 목표는 모든 명령 처리기의 handle 메서드에서 사용자 지정 부분을 짜는 것입니다.java.lang.NoSuchMethodError : ..... EventProcessor : 메서드 <init>() V 찾을 수 없음

내 사용자 측면 :

@Aspect 
@Component 
class EventProcessor @Autowired()(private val eventRepository: EventRepository) { 

    @Before("execution(* com.mypackage.*.application.commands.*.*(..))") 
    def listen() { 
    DomainEventPublisher.instance().subscribe(new DomainEventSubscriber[Event] { 

     def handleEvent(domainEvent: Event) { 
     eventRepository.save(domainEvent) 
     } 

     def subscribedToEventType = { 
     classOf[Event] 
     } 
    }) 
    } 

} 

commandHandler의 예 : 사용자 정의 측면이 런타임에서 길쌈 할 때

trait CommentBlog { 

    def handle(command: MyCommand): ValidationNel[Failure, Unit] 

} 

전체가 잘 작동합니다. 프로덕션을 위해 컴파일 시간에 직조되기를 기대하며,이를 달성하기 위해 큰 plugin을 사용합니다.

java.lang.NoSuchMethodError: .....EventProcessor: method <init>()V not found 

정확히 init을이 방법 무엇입니까 : 실행할 때

그러나,이 오류에 의한 NoAspectBoundException를 얻을? 근본 원인은 무엇일까요? 이 정의되지 않았기 때문에

+0

AOP와 관련된 어떤 생각하지만, 플러그인은 단순히 EventProcessor''의 기본 생성자를 찾을 수없는 것 같습니다 :

그래서 내 해결책은 없다. – Landei

+0

그러나 플러그인은 컴파일 타임에 내 클래스에'@ Transactional' aspect를 짜는 데 성공했습니다. – Mik378

+0

아주 이상한 ... – Mik378

답변

1
난 그냥 물건 : @Landei으로

가 제기를 발견했습니다

는 기본 생성자를 찾을 수 없습니다! 스칼라에서 :

class EventProcessor @Autowired()(private val eventRepository: EventRepository) {EventRepository을 수락하는 하나의 인수 생성자를 생성합니다.

@Aspect 
class EventProcessor { 

    @Before("execution(* com.mypackage.*.application.commands.*.*(..))") 
    def listen() { 
    DomainEventPublisher.instance().subscribe(new DomainEventSubscriber[Event] { 

     def handleEvent(domainEvent: Event) { 
     val eventRepository = SpringContext.ctx.getBean("eventRepository", classOf[EventRepository]) 
     eventRepository.save(domainEvent) 
     } 

     def subscribedToEventType = { 
     classOf[Event] 
     } 
    }) 
    } 

} 
관련 문제