日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網(wǎng)為廣大站長(zhǎng)提供免費(fèi)收錄網(wǎng)站服務(wù),提交前請(qǐng)做好本站友鏈:【 網(wǎng)站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(wù)(50元/站),

點(diǎn)擊這里在線咨詢(xún)客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會(huì)員:747

本文介紹了Spring AOP錯(cuò)誤無(wú)法懶惰地為此建議構(gòu)建thisJoinPoint的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

切入點(diǎn)聲明:

@Pointcut(value="com.someapp.someservice.someOperation() && args(t,req)",argNames="t,req")
private void logOperationArg(final String t,final String req)
{
}

建議聲明未編譯:

@Before(value="logOperationArg(t,req)")
public void logBeforeOperationAdvice(JoinPoint jp, final String t, final String req){
...
}

使用AspectJ-maven-plugin(1.5版)編譯方面時(shí),出現(xiàn)錯(cuò)誤"can not build thisJoinPoint lazily for this advice since it has no suitable guard [Xlint:noGuardForLazyTjp]"

但編譯相同的建議時(shí)不使用JoinPoint參數(shù)。

建議聲明匯編:

@Before(value="logOperationArg(t,req)")
public void logBeforeOperationAdvice(final String t, final String req){
...
}

推薦答案

Spring AOP僅支持method join points,因?yàn)樗?code>dynamic proxies在需要時(shí)創(chuàng)建代理對(duì)象(例如,如果您使用的是ApplicationContext,則它將在從BeanFactory加載Bean后創(chuàng)建)

使用execution()語(yǔ)句匹配作為方法執(zhí)行的連接點(diǎn)。

例如:

class LogAspect {

@Before("execution(* com.test.work.Working(..))")
public void beginBefore(JoinPoint join){

System.out.println("This will be displayed before Working() method will be executed");
}

現(xiàn)在如何聲明您的BO:

//.. declare interface

然后:

class BoModel implements SomeBoInterface {

public void Working(){
System.out.println("It will works after aspect");
     }
}

execution()語(yǔ)句是PointCut表達(dá)式,用于告知應(yīng)將建議應(yīng)用于何處。

如果您喜歡使用@PointCut,可以這樣做:

class LogAspect {

//define a pointcut
@PointCut(
        "execution(* com.test.work.SomeInferface.someInterfaceMethod(..))")
     public void PointCutLoc() {
}

@Before("PointCutLoc()")
public void getBefore(){
System.out.println("This will be executed before someInterfaceMethod()");
      }

}

第2部分:

此外,該錯(cuò)誤還表明您沒(méi)有保護(hù)您的建議。從技術(shù)上講,Guard使您的代碼更快,因?yàn)槟恍枰诿看螆?zhí)行它時(shí)都構(gòu)造thisJoinPoint。因此,如果沒(méi)有意義,您可以嘗試忽略它

canNotImplementLazyTjp = ignore
multipleAdviceStoppingLazyTjp=ignore
noGuardForLazyTjp=ignore

這篇關(guān)于Spring AOP錯(cuò)誤無(wú)法懶惰地為此建議構(gòu)建thisJoinPoint的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,

分享到:
標(biāo)簽:AOP Spring thisJoinPoint 建議 懶惰 構(gòu)建 錯(cuò)誤
用戶(hù)無(wú)頭像

網(wǎng)友整理

注冊(cè)時(shí)間:

網(wǎng)站:5 個(gè)   小程序:0 個(gè)  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會(huì)員

趕快注冊(cè)賬號(hào),推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨(dú)大挑戰(zhàn)2018-06-03

數(shù)獨(dú)一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過(guò)答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫(kù),初中,高中,大學(xué)四六

運(yùn)動(dòng)步數(shù)有氧達(dá)人2018-06-03

記錄運(yùn)動(dòng)步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績(jī)?cè)u(píng)定2018-06-03

通用課目體育訓(xùn)練成績(jī)?cè)u(píng)定