3 回答

TA貢獻1811條經驗 獲得超5個贊
問題已解決,但仍有問題。
我正在使用 2 個方面類,其順序設置為Ordered.HIGHEST_PRECEDENCE
和Ordered.LOWEST_PRECEDENCE
。如果我Ordered.HIGHEST_PRECEDENCE
用另一個值替換訂單值,錯誤就會消失。相當奇怪的現象,異常顯示與實際原因無關。有誰知道真正的原因?

TA貢獻1725條經驗 獲得超8個贊
這是因為ExposeInvocationInterceptor沒有先加載,導致userAttributes不會被Spring Bean (for CacheFetch)注入參數。
您也可以在以下位置找到評論:
No MethodInvocation found: Check that an AOP invocation is in progress,
and that the ExposeInvocationInterceptor is upfront in the interceptor chain. Specifically,
note that advices with order HIGHEST_PRECEDENCE will execute before ExposeInvocationInterceptor!
并且還有一個問題嘗試通過使用來解決此問題PriorityOrdered,但似乎仍未解決。
因此,對于您的問題,有兩種解決方案可以解決此問題:
改變
Ordered
不HIGHEST_PRECEDENCE
,也許HIGHEST_PRECEDENCE+1
手動注入 bean
ApplicationContext.getBean

TA貢獻2037條經驗 獲得超6個贊
我發現了另一種情況,可能會使 中的調用無效Exposeinvocationinterceptor
,導致org.springframework.aop.aspectj.aspectjexpressionpointcut ? matches (java.lang.reflect.method, java.lang.class <? >, Java. Lang.Object...)
無法獲得有效的方法調用。
具體情況:當有多個aspect時,當一個高優先級aspect異步處理時joinpoint.Processed()
,下一個aspect會切換到一個新的線程,所以無法獲取到ThreadLocal變量。
添加回答
舉報