Browse Source

调回注解消除自动注入(autowiring)的歧义

ZJY 6 months ago
parent
commit
3faf1f53bc

+ 5 - 4
usky-common/usky-common-log/src/main/java/com/usky/common/log/aspect/LogAspect.java

@@ -7,7 +7,6 @@ import java.util.Objects;
 import java.util.concurrent.TimeUnit;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import javax.xml.crypto.Data;
 
 import com.alibaba.fastjson.JSON;
 import com.usky.common.core.util.IpUtils;
@@ -42,11 +41,13 @@ public class LogAspect {
     @Autowired
     private AsyncLogService asyncLogService;
 
-    @Pointcut("@annotation(controllerLog)")
-    public void logPointcut(Log controllerLog) {
+    // 定义切入点,使用@annotation指示器
+    @Pointcut("@annotation(com.usky.common.log.annotation.Log)")
+    public void logPointcut() {
     }
 
-    @Around("logPointcut(controllerLog)")
+    // 环绕通知,引用切入点并传递注解实例
+    @Around("logPointcut() && @annotation(controllerLog)")
     public Object aroundLog(ProceedingJoinPoint joinPoint, Log controllerLog) throws Throwable {
         Date startTime = new Date();
         Object result = null;

+ 1 - 1
usky-common/usky-common-log/src/main/java/com/usky/common/log/service/AsyncLogService.java

@@ -15,7 +15,7 @@ import org.springframework.stereotype.Service;
 @Service
 public class AsyncLogService
 {
-    @Qualifier("sysLogControllerApi")
+    @Qualifier("com.usky.system.RemoteLogService")
     @Autowired
     private RemoteLogService remoteLogService;