File tree Expand file tree Collapse file tree 4 files changed +44
-2
lines changed
spring-boot-data-aggregator-example
java/io/github/lvyahui8/spring/example Expand file tree Collapse file tree 4 files changed +44
-2
lines changed Original file line number Diff line number Diff line change 2727 <groupId >org.springframework.boot</groupId >
2828 <artifactId >spring-boot-starter</artifactId >
2929 </dependency >
30+ <dependency >
31+ <groupId >org.springframework.boot</groupId >
32+ <artifactId >spring-boot-starter-aop</artifactId >
33+ </dependency >
3034 <dependency >
3135 <groupId >org.springframework.boot</groupId >
3236 <artifactId >spring-boot-starter-test</artifactId >
Original file line number Diff line number Diff line change 1717 * @since 2019/6/1 0:13
1818 */
1919
20- @ SpringBootApplication
20+ @ SpringBootApplication ( scanBasePackages = "io.github.lvyahui8.spring.example" )
2121@ Slf4j
2222public class ExampleApplication {
2323
Original file line number Diff line number Diff line change 1+ package io .github .lvyahui8 .spring .example .aspect ;
2+
3+ import lombok .extern .slf4j .Slf4j ;
4+ import org .aspectj .lang .ProceedingJoinPoint ;
5+ import org .aspectj .lang .annotation .Around ;
6+ import org .aspectj .lang .annotation .Aspect ;
7+ import org .aspectj .lang .annotation .Pointcut ;
8+ import org .springframework .stereotype .Component ;
9+
10+ /**
11+ * @author lvyahui (lvyahui8@gmail.com,lvyahui8@126.com)
12+ * @since 2019/7/7 23:17
13+ */
14+ @ Aspect
15+ @ Component
16+ @ Slf4j
17+ public class AggregateQueryLoggingAspect {
18+
19+ public AggregateQueryLoggingAspect () {
20+ log .info ("init aspect bean" );
21+ }
22+
23+ @ Pointcut ("execution(* io.github.lvyahui8.spring.aggregate.service.impl.DataBeanAggregateQueryServiceImpl.*(..))" )
24+ public void aggregateQuery () {}
25+
26+ @ Around ("execution(* io.github.lvyahui8.spring.aggregate.service.impl.DataBeanAggregateQueryServiceImpl.*(..))" )
27+ public Object doLogging (ProceedingJoinPoint joinPoint ) throws Throwable {
28+ Object retVal ;
29+ try {
30+ retVal = joinPoint .proceed ();
31+ } finally {
32+ log .info ("x" );
33+ }
34+ return retVal ;
35+ }
36+ }
Original file line number Diff line number Diff line change 11spring.main.banner-mode =off
22io.github.lvyahui8.spring.base-packages =io.github.lvyahui8.spring.example
33io.github.lvyahui8.spring.ignore-exception =false
4- io.github.lvyahui8.spring.enable-logging =false
4+ io.github.lvyahui8.spring.enable-logging =false
5+ spring.aop.auto =true
6+ spring.aop.proxy-target-class =true
You can’t perform that action at this time.
0 commit comments