This commit is contained in:
wyl
2022-05-29 23:40:19 +08:00
parent 4f99ed9b24
commit 35dbe9f827
6 changed files with 34 additions and 6 deletions
+4 -4
View File
@@ -3,10 +3,10 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <artifactId>spring-boot</artifactId>
<artifactId>spring-boot-starter-parent</artifactId> <groupId>com.wyl.example</groupId>
<version>2.6.7</version> <version>1.0-SNAPSHOT</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<groupId>com.wyl</groupId> <groupId>com.wyl</groupId>
<artifactId>spring-boot-common</artifactId> <artifactId>spring-boot-common</artifactId>
@@ -22,7 +22,11 @@ public class LogAspect {
/** /**
* 以自定义 @WebLog 注解为切点 * 以自定义 @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() { public void webLog() {
} }
@@ -10,4 +10,5 @@ public interface LogTestService {
void testSPEL(Order order); void testSPEL(Order order);
void testSPELList(List<Order> orders); void testSPELList(List<Order> orders);
} }
@@ -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);
}
}
@@ -11,7 +11,7 @@ import java.util.List;
@Service @Service
public class LogTestServiceImpl implements LogTestService { public class LogTestServiceImpl implements LogTestService {
@Override @Override
@LogTest // @LogTest
public void test() { public void test() {
System.out.println("testLog"); System.out.println("testLog");
} }
@@ -1,6 +1,7 @@
package com.wyl.spring.boot.common; package com.wyl.spring.boot.common;
import com.wyl.spring.boot.common.service.LogTestService; 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 com.wyl.spring.boot.common.spel.bean.Order;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -15,8 +16,12 @@ class SpringBootCommonApplicationTests {
@Autowired @Autowired
LogTestService logTestService; LogTestService logTestService;
@Autowired
AopTest aopTest;
@Test @Test
void beanInit() { void beanInit() {
aopTest.aopLog2();
} }
@Test @Test