Maven project structure is as follows
pom.xml and SpringBoot related content
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.8.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
</dependencies>
SampleController.java
@Controller
@EnableAutoConfiguration
@ComponentScan
public class SampleController {
@RequestMapping("/")
@ResponseBody
String home() {
return "Hello World!";
}
public static void main(String[] args) throws Exception {
SpringApplication.run(SampleController.class, args);
}
}
CustomAspect
@Aspect
@Component
public class CustomAspect {
@Pointcut("execution(public * com.demo..*.*(..))")
public void customPoint(){}
@Before(value = "customPoint()")
public void deBefore(JoinPoint joinPoint) throws Throwable {
System.out.println("...");
}
}
visit the http://localhost:8080/ page to display Hello word!
but does not show AOP interception information [intercept request.] and no exception is reported. I hope you can"t find the problem