Spring boot 尽管在表达式中指定了确切的名称,但切入点表达式与Spring数据方法不匹配

Spring boot 尽管在表达式中指定了确切的名称,但切入点表达式与Spring数据方法不匹配,spring-boot,spring-data-jpa,aop,spring-aop,Spring Boot,Spring Data Jpa,Aop,Spring Aop,在我的SpringBoot项目中,我有AddressRepository,它从数据库中获取所有地址。我有一个方面类和一个切入点表达式,它在调用findAll()方法之后执行。当我执行我的测试用例时,不会触发通知,其他方法,如findAll(Sort-Sort),findAll(Pageable-Pageable)工作正常。我不确定这是Spring Boot的bug还是我的表达式。我试过使用SpringBoot2.0.5和2.1.0,但似乎没有什么能解决我的问题 AddressLogging.ja

在我的SpringBoot项目中,我有AddressRepository,它从数据库中获取所有地址。我有一个方面类和一个切入点表达式,它在调用
findAll()
方法之后执行。当我执行我的测试用例时,不会触发通知,其他方法,如
findAll(Sort-Sort)
findAll(Pageable-Pageable)
工作正常。我不确定这是Spring Boot的bug还是我的表达式。我试过使用SpringBoot2.0.5和2.1.0,但似乎没有什么能解决我的问题

AddressLogging.java

@方面
@配置
公共类地址记录{
私有日志记录器log=LoggerFactory.getLogger(AddressLogging.class);
//@切入点(“执行(*com.springtesting.repo.AddressRepository.*(..)”)
@切入点(“执行(*com.springtesting.repo.AddressRepository.findAll()))
public void getAddresses(){}
@之后(“getAddresses()”)
公众谘询({
错误(“日志消息:在afterAdvice()通知中”);
}
}
AopTest.java

@RunWith(SpringRunner.class)
@春靴测试
公共类AopTest{
@自动连线
专用地址存储库地址存储库;
@试验
公共地址(){
//addressRepository.findAll(PageRequest.of(0,20,排序方式(“id”)));
addressRepository.findAll();
}
@试验
public void findAddressById(){
addressRepository.findById(1L);
}
}
地址存储库

public interface AddressRepository扩展了JpaRepository{}

Spring AOP特性也应该是
@组件
,并通过组件扫描获取。我不知道为什么要将
@Configuration
添加到方面,因为这里没有配置

也许您对单独配置类的测试应该带有
@configuration
注释,并且您还应该激活类似
@enableAspectJautProxy(proxyTargetClass=true)
@ComponentScan(basePackages={“de.scrum\u master”})
的东西

下面是我的一个Spring AOP游乐场项目的一个片段(我很少使用它,我不使用Spring AOP,甚至不使用Spring本身,通常我使用更强大的AspectJ:

package de.scrum\u master.app;
导入org.springframework.context.ApplicationContext;
导入org.springframework.context.annotation.AnnotationConfigApplicationContext;
导入org.springframework.context.annotation.ComponentScan;
导入org.springframework.context.annotation.Configuration;
导入org.springframework.context.annotation.enableAspectProxy;
@配置
@EnableSpectProxy(proxyTargetClass=true)
@ComponentScan(basePackages={“de.scrum_master”})
公共类应用程序2{
公共静态void main(字符串[]args)引发异常{
ApplicationContext appContext=新注释ConfigApplicationContext(Application2.class);
B=(B)appContext.getBean(“B”);
System.out.println(b.getData(“bbb”);
A=(A)appContext.getBean(“b”);
System.out.println(a.getData(“aaa”);
}
}