簡體   English   中英

原因:java.lang.IllegalArgumentException: error at::0 切入點中的正式未綁定

[英]Caused by: java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut

我已經檢查了其他類似的 SO 問題,但似乎沒有一個適用。

我有我的服務 class:

package com.test.demo.service;

import com.test.demo.controller.Controller2;
import com.test.demo.model.SettlementTransaction;
import org.springframework.stereotype.Service;

@Service
public class TestService {

    public Controller2.AcctDetails testAcctDeets(Transaction transaction){

和我的方面:

@AfterReturning(pointcut = "execution(* com.test.demo.service.TestService.testAcctDeets(..))", returning = "response")
public void interceptRequest(Controller2.AcctDetails response, JoinPoint thisJoinPoint) {
    System.out.println(thisJoinPoint);
    for (Object arg : thisJoinPoint.getArgs()) {
        if (arg instanceof String)
            System.out.println("  request = " + arg);
    }
    System.out.println("  response = " + response.toString());
}

但我不斷收到錯誤:

原因:java.lang.IllegalArgumentException: error at::0 切入點中的正式未綁定

任何幫助表示贊賞。 謝謝!

來自參考文檔: 訪問當前

任何通知方法都可以將org.aspectj.lang.JoinPoint類型的參數聲明為它的第一個參數(注意,圍繞通知需要聲明ProceedingJoinPoint類型的第一個參數,它是JoinPoint的子類

這被記錄為主題Advice Parameters的延續,該主題引用了這一點: Spring 提供完全類型化的建議,這意味着您在建議簽名中聲明所需的參數(正如我們前面看到的返回和拋出示例)

當一起閱讀時,當傳遞通知參數並且通知方法也有JointPoint或其任何子類作為另一個參數時,后者應聲明為第一個參數。

所以在這種情況下,有效的方法簽名將是

@AfterReturning(pointcut = "execution(* com.test.demo.service.TestService.testAcctDeets(..))", returning = "response")
public void interceptRequest(JoinPoint thisJoinPoint, Controller2.AcctDetails response) {
    // ..
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM