Browse Source

feat:ios服务配置修复

hidewnd 1 tuần trước cách đây
mục cha
commit
d2dd6d2f1c

+ 19 - 1
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/config/YtWebMvcConfigurerAdapter.java

@@ -1,19 +1,37 @@
 package com.ytpm.lemonios.config;
 
 import com.ytpm.lemonios.config.interceptor.HttpInterceptor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+
 /**
  * 自定义拦截器
  */
+@Slf4j
 @Configuration
 public class YtWebMvcConfigurerAdapter implements WebMvcConfigurer {
 
+    @Resource
+    private HttpInterceptor httpInterceptor;
+
+    @Value("${spring.application.name:}")
+    private String applicationName;
 
     @Override
     public void addInterceptors(InterceptorRegistry registry) {
-        registry.addInterceptor(new HttpInterceptor()).addPathPatterns("/**").excludePathPatterns("/resources/**");
+        registry.addInterceptor(httpInterceptor).
+                addPathPatterns("/**")
+                .excludePathPatterns("/resources/**");
+    }
+
+    @PostConstruct
+    private void handlePostConstruct() {
+        log.info("current service: {}", applicationName);
     }
 }