From 35dbe9f827b078b6d1f5e32d4edf527ba7495c2e Mon Sep 17 00:00:00 2001 From: wyl <959814898@qq.com> Date: Sun, 29 May 2022 23:40:19 +0800 Subject: [PATCH] test --- spring-boot/spring-boot-common/pom.xml | 8 ++++---- .../boot/common/aop/aspect/LogAspect.java | 6 +++++- .../boot/common/service/LogTestService.java | 1 + .../boot/common/service/impl/AopTest.java | 18 ++++++++++++++++++ .../service/impl/LogTestServiceImpl.java | 2 +- .../SpringBootCommonApplicationTests.java | 5 +++++ 6 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 spring-boot/spring-boot-common/src/main/java/com/wyl/spring/boot/common/service/impl/AopTest.java diff --git a/spring-boot/spring-boot-common/pom.xml b/spring-boot/spring-boot-common/pom.xml index 9dbc8b1..544849f 100644 --- a/spring-boot/spring-boot-common/pom.xml +++ b/spring-boot/spring-boot-common/pom.xml @@ -3,10 +3,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.springframework.boot - spring-boot-starter-parent - 2.6.7 - + spring-boot + com.wyl.example + 1.0-SNAPSHOT + ../pom.xml com.wyl spring-boot-common diff --git a/spring-boot/spring-boot-common/src/main/java/com/wyl/spring/boot/common/aop/aspect/LogAspect.java b/spring-boot/spring-boot-common/src/main/java/com/wyl/spring/boot/common/aop/aspect/LogAspect.java index 23ef6cd..7dbb915 100644 --- a/spring-boot/spring-boot-common/src/main/java/com/wyl/spring/boot/common/aop/aspect/LogAspect.java +++ b/spring-boot/spring-boot-common/src/main/java/com/wyl/spring/boot/common/aop/aspect/LogAspect.java @@ -22,7 +22,11 @@ public class LogAspect { /** * 以自定义 @WebLog 注解为切点 */ - @Pointcut("@annotation(com.wyl.spring.boot.common.aop.annotation.LogTest)") +// @Pointcut("@annotation(com.wyl.spring.boot.common.aop.annotation.LogTest)") +// public void webLog() { +// } + + @Pointcut("execution(* com.wyl.spring.boot.common.service.impl.AopTest.aopLog())") public void webLog() { } diff --git a/spring-boot/spring-boot-common/src/main/java/com/wyl/spring/boot/common/service/LogTestService.java b/spring-boot/spring-boot-common/src/main/java/com/wyl/spring/boot/common/service/LogTestService.java index b1782d1..0221fec 100644 --- a/spring-boot/spring-boot-common/src/main/java/com/wyl/spring/boot/common/service/LogTestService.java +++ b/spring-boot/spring-boot-common/src/main/java/com/wyl/spring/boot/common/service/LogTestService.java @@ -10,4 +10,5 @@ public interface LogTestService { void testSPEL(Order order); void testSPELList(List orders); + } diff --git a/spring-boot/spring-boot-common/src/main/java/com/wyl/spring/boot/common/service/impl/AopTest.java b/spring-boot/spring-boot-common/src/main/java/com/wyl/spring/boot/common/service/impl/AopTest.java new file mode 100644 index 0000000..75df206 --- /dev/null +++ b/spring-boot/spring-boot-common/src/main/java/com/wyl/spring/boot/common/service/impl/AopTest.java @@ -0,0 +1,18 @@ +package com.wyl.spring.boot.common.service.impl; + +import org.aspectj.weaver.ast.Test; +import org.springframework.stereotype.Service; + +@Service +public class AopTest { + + public void aopLog2() + { + aopLog(); + } + + public void aopLog() + { + System.out.println(1); + } +} diff --git a/spring-boot/spring-boot-common/src/main/java/com/wyl/spring/boot/common/service/impl/LogTestServiceImpl.java b/spring-boot/spring-boot-common/src/main/java/com/wyl/spring/boot/common/service/impl/LogTestServiceImpl.java index 67c844d..352f754 100644 --- a/spring-boot/spring-boot-common/src/main/java/com/wyl/spring/boot/common/service/impl/LogTestServiceImpl.java +++ b/spring-boot/spring-boot-common/src/main/java/com/wyl/spring/boot/common/service/impl/LogTestServiceImpl.java @@ -11,7 +11,7 @@ import java.util.List; @Service public class LogTestServiceImpl implements LogTestService { @Override - @LogTest +// @LogTest public void test() { System.out.println("testLog"); } diff --git a/spring-boot/spring-boot-common/src/test/java/com/wyl/spring/boot/common/SpringBootCommonApplicationTests.java b/spring-boot/spring-boot-common/src/test/java/com/wyl/spring/boot/common/SpringBootCommonApplicationTests.java index fa8fcad..416282d 100644 --- a/spring-boot/spring-boot-common/src/test/java/com/wyl/spring/boot/common/SpringBootCommonApplicationTests.java +++ b/spring-boot/spring-boot-common/src/test/java/com/wyl/spring/boot/common/SpringBootCommonApplicationTests.java @@ -1,6 +1,7 @@ package com.wyl.spring.boot.common; import com.wyl.spring.boot.common.service.LogTestService; +import com.wyl.spring.boot.common.service.impl.AopTest; import com.wyl.spring.boot.common.spel.bean.Order; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -15,8 +16,12 @@ class SpringBootCommonApplicationTests { @Autowired LogTestService logTestService; + @Autowired + AopTest aopTest; + @Test void beanInit() { + aopTest.aopLog2(); } @Test