|
|
@@ -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);
|
|
|
}
|
|
|
}
|