第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

CrudRepository 和 Annotation 上的 Spring + AspectJ

CrudRepository 和 Annotation 上的 Spring + AspectJ

梵蒂岡之花 2021-06-15 13:01:03
我有 @Tenantable 注釋來(lái)決定 pointCut :@Target({ElementType.TYPE, ElementType.METHOD})@Retention(RetentionPolicy.RUNTIME)@Inheritedpublic @interface Tenantable {}這是我的方面: @Slf4j    @Aspect    @Configuration    public class TenancyAspect {        @Pointcut("execution(public * *(..))")        public void publicMethod() {}        @Around("publicMethod() && @within(com.sam.example.aspect.aspectexample.model.Tenantable)")        public Object tenatable(ProceedingJoinPoint joinPoint) throws Throwable {            System.out.println("my operations ...");            return joinPoint.proceed();        }    }這對(duì)于這個(gè)服務(wù)類沒(méi)有任何問(wèn)題:@Tenantable@Servicepublic class MyService(){    public void doSomething(){            ...    }}當(dāng)我調(diào)用 doSomething() 方法時(shí),我的方面正在運(yùn)行,沒(méi)關(guān)系,但我想為屬于 spring 數(shù)據(jù)的 CrudRepository 接口實(shí)現(xiàn)方面。我已經(jīng)改變了我的方面來(lái)實(shí)現(xiàn)這個(gè),如下所示:@Slf4j@Aspect@Configurationpublic class TenancyAspect {    @Pointcut("execution(public * *(..))")    public void publicMethod() {}    @Pointcut("this(org.springframework.data.repository.Repository)")    public void repositoryExec(){}    @Around("publicMethod() && repositoryExec() && @within(com.sam.example.aspect.aspectexample.model.Tenantable)")    public Object tenatable(ProceedingJoinPoint joinPoint) throws Throwable {        System.out.println("my operations ...");        return joinPoint.proceed();    }}這是存儲(chǔ)庫(kù):@Tenantable@Repositorypublic interface MyRepository extends CrudRepository{}但是當(dāng)我調(diào)用 MyRepository 中的任何方法時(shí)它不起作用。有沒(méi)有辦法做到這一點(diǎn)?編輯: 當(dāng)我應(yīng)用這些時(shí),它適用于所有存儲(chǔ)庫(kù):@Pointcut("execution(public * org.springframework.data.repository.Repository+.*(..))")并排除這個(gè):@within(com.sam.example.aspect.aspectexample.model.Tenantable)但是我需要這個(gè)注釋才能將它應(yīng)用于特定的存儲(chǔ)庫(kù)。
查看完整描述

2 回答

  • 2 回答
  • 0 關(guān)注
  • 157 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)