screen-api/src/main/java/com/moral/api/config/Interceptor/WebAppConfiguration.java
@@ -1,18 +1,31 @@ package com.moral.api.config.Interceptor; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import com.moral.api.interceptor.AuthenticationInterceptor; import java.util.ArrayList; import com.moral.api.interceptor.WebInterceptor; @Configuration public class WebAppConfiguration implements WebMvcConfigurer { //读取不需拦截路径 @Bean @ConfigurationProperties("mvc.interceptor.exclude") public ArrayList<String> getExcludePath(){ return new ArrayList<>(); } @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new AuthenticationInterceptor()) .addPathPatterns("/**") .excludePathPatterns("/**/login/**", "/**/logout/**", "/swagger-ui.html/**", "/swagger-resources/**","/**/verificationCode/**","/**/user/**"); InterceptorRegistration regisration = registry.addInterceptor(new WebInterceptor()); ArrayList<String> excludePath = getExcludePath(); regisration.addPathPatterns("/**/**");//设置拦截路径 regisration.excludePathPatterns(excludePath);//设置不拦截路径 } } screen-api/src/main/java/com/moral/api/interceptor/WebInterceptor.java
File was renamed from screen-api/src/main/java/com/moral/api/interceptor/AuthenticationInterceptor.java @@ -7,11 +7,10 @@ import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.HandlerInterceptor; import com.moral.redis.RedisUtil; import com.moral.util.TokenUtils; @Component public class AuthenticationInterceptor implements HandlerInterceptor { public class WebInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { screen-api/src/main/resources/application-dev.yml
@@ -14,32 +14,28 @@ profiles: active: dev application: name: screen-api name: screen-manage redis: #cluster: #nodes: 47.112.126.78:7001,47.112.126.78:7002,47.112.126.132:7003,47.112.126.132:7004,47.112.132.193:7005,47.112.132.193:7006 #password: test #timeout: 500 host: 39.97.177.149 port: 6379 password: chenkaiyu111 timeout: 30000 jedis: pool: max-active: 256 max-wait: 30000 max-idle: 64 min-idle: 32 lettuce: pool: max-active: 256 max-idle: 64 max-wait: 30000 min-idle: 32 tokenRedis: host: 39.97.177.149 host: r-bp1xdlb9wfc6zt0msp.redis.rds.aliyuncs.com port: 6379 password: chenkaiyu111 password: moral_123456 timeout: 30000 jedis: pool: max-active: 256 max-wait: 30000 max-idle: 64 min-idle: 32 lettuce: pool: max-active: 256 max-idle: 64 max-wait: 30000 min-idle: 32 tokenRedis: host: r-bp1xdlb9wfc6zt0msp.redis.rds.aliyuncs.com port: 6379 password: moral_123456 timeout: 30000 database: 15 pool: @@ -57,9 +53,9 @@ filters: stat type: com.alibaba.druid.pool.DruidDataSource max-wait: 60000 url: jdbc:mysql://39.97.177.149:3306/moral?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai url: jdbc:mysql://rm-bp1pr3rx9m3fnkwsk.mysql.rds.aliyuncs.com:3306/moral?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai username: root password: chenkaiyu111 password: moral_123456 test-on-borrow: false sql-script-encoding: utf-8 pool-prepared-statements: true @@ -113,7 +109,13 @@ mvc: interceptor: exclude: - /account/login - /login - /swagger-ui.html - /swagger-resources/** - /swagger-ui.html/** - /webjars/** - /verificationCode/** AES: KEY: AD42F7787B035B7580000EF93BE20BAD