Spring Data的@DomainEvents
與AbstractAggregateRoot
工作很好,但在其使用的域對象上失敗repository.save(Iterable<S> entities)
。Spring Data @DomainEvents和AbstractAggregateRoot保存失敗(列表<S>迭代)
的錯誤跟蹤如下: -
java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:216)
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:201)
at org.springframework.data.repository.core.support.EventPublishingRepositoryProxyPostProcessor$EventPublishingMethod.publishEventsFrom(EventPublishingRepositoryProxyPostProcessor.java:173)
at org.springframework.data.repository.core.support.EventPublishingRepositoryProxyPostProcessor$EventPublishingMethodInterceptor.invoke(EventPublishingRepositoryProxyPostProcessor.java:97)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57)
at org.springframework.aop.framework.
的問題是導致clearDomainEvents(…)
在上述情況下被施加爲每下面的代碼在EventPublishingRepositoryProxyPostProcessor
if (clearingMethod != null) {
ReflectionUtils.invokeMethod(clearingMethod, object);
}
如果將是巨大的這可以解決或我在這裏錯過了一些東西。
你試過調試嗎? – emotionlessbananas
燁試圖試圖調用對象的clearDomainEvents方法在保存(迭代)的情況下是一個列表,發佈它的事件處理,但clearDomainEvents以及它應該把邏輯。 –
如果我理解正確,即使您的事件處理代碼爲空,也會得到此異常?如果是這種情況,請提交錯誤。 –