Commit cfdb0c60 by 刘宇峰

整理框架

1 parent 4e481a83
Showing 46 changed files with 48 additions and 98 deletions
......@@ -17,21 +17,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<spring-cloud.version>Hoxton.SR9</spring-cloud.version>
<spring-cloud-alibaba.version>2.2.6.RELEASE</spring-cloud-alibaba.version>
<rest-admin-framework.version>2.0.0-SNAPSHOT</rest-admin-framework.version>
<!-- <repo.internal.snapshots.url>https://repo1.maven.org/maven2</repo.internal.snapshots.url>-->
<!-- <repo.internal.releases.url>https://repo1.maven.org/maven2</repo.internal.releases.url>-->
<!-- <repo.proxy.url>https://repo1.maven.org/maven2</repo.proxy.url>-->
<!-- <repo.external.url>https://repo1.maven.org/maven2</repo.external.url>-->
<local.nexus.snapshots.url>http://192.168.3.233/nexus/content/repositories/snapshots/</local.nexus.snapshots.url>
<local.nexus.releases.url>http://192.168.3.233/nexus/content/repositories/releases/</local.nexus.releases.url>
</properties>
<dependencies>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
......@@ -53,7 +40,7 @@
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-framework-dependencies</artifactId>
<version>${rest-admin-framework.version}</version>
<version>${revision}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
......
......@@ -29,7 +29,6 @@
<groupId>com.glsx</groupId>
<artifactId>rest-admin-core</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<!-- feign -->
......@@ -37,7 +36,6 @@
<groupId>com.glsx</groupId>
<artifactId>rest-admin-feign</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<!--oauth2认证-->
......
......@@ -21,20 +21,14 @@
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-alliance</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-core</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-mybatis</artifactId>
<version>1.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<!-- spring security -->
<dependency>
......@@ -45,7 +39,6 @@
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.2.1.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
......
......@@ -21,14 +21,10 @@
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-alliance</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-mybatis</artifactId>
<version>1.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<!-- spring security -->
......
......@@ -9,7 +9,7 @@
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<artifactId>glsx-rest-admin-gateway-server</artifactId>
<artifactId>rest-admin-gateway-archetype</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
......
......@@ -2,6 +2,7 @@ package com.glsx.plat.gateway.exception;
import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.web.error.ErrorAttributeOptions;
import org.springframework.boot.web.reactive.error.DefaultErrorAttributes;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
......@@ -9,6 +10,7 @@ import org.springframework.web.reactive.function.server.ServerRequest;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
/**
* @author payu
......@@ -18,11 +20,11 @@ import java.util.Map;
public class GlobalErrorAttributes extends DefaultErrorAttributes {
@Override
public Map<String, Object> getErrorAttributes(ServerRequest request, boolean includeStackTrace) {
public Map<String, Object> getErrorAttributes(ServerRequest request, ErrorAttributeOptions options) {
//简单返回
if (!includeStackTrace) return assembleError(request);
if (Objects.isNull(options)) return assembleError(request);
Map<String, Object> map = super.getErrorAttributes(request, includeStackTrace);
Map<String, Object> map = super.getErrorAttributes(request, options);
if (getError(request) instanceof GlobalException) {
GlobalException ex = (GlobalException) getError(request);
map.put(R.MSG_KEY, ex.getMessage());
......
package com.glsx.plat.gateway.exception;
import org.springframework.boot.autoconfigure.web.ResourceProperties;
import org.springframework.boot.autoconfigure.web.WebProperties;
import org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler;
import org.springframework.boot.web.reactive.error.ErrorAttributes;
import org.springframework.context.ApplicationContext;
......@@ -24,7 +24,7 @@ public class GlobalErrorWebExceptionHandler extends AbstractErrorWebExceptionHan
public GlobalErrorWebExceptionHandler(GlobalErrorAttributes g, ApplicationContext applicationContext,
ServerCodecConfigurer serverCodecConfigurer) {
super(g, new ResourceProperties(), applicationContext);
super(g, new WebProperties.Resources(), applicationContext);
super.setMessageWriters(serverCodecConfigurer.getWriters());
super.setMessageReaders(serverCodecConfigurer.getReaders());
}
......
......@@ -27,6 +27,7 @@ import reactor.core.publisher.Mono;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Objects;
/**
* @author payu
......@@ -36,7 +37,7 @@ import java.util.Arrays;
@RefreshScope
public class AuthGlobalFilter implements GlobalFilter, Ordered {
@Value("${auth.skip.urls}")
@Value("${auth.skip.urls:#{null}}")
private String[] skipAuthUrls;
@Autowired
......@@ -57,7 +58,7 @@ public class AuthGlobalFilter implements GlobalFilter, Ordered {
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
String url = exchange.getRequest().getURI().getPath();
//跳过不需要验证的路径
if (Arrays.asList(skipAuthUrls).contains(url)) {
if (!Objects.isNull(skipAuthUrls) && Arrays.asList(skipAuthUrls).contains(url)) {
return chain.filter(exchange);
}
......
spring.application.name=rest-admin-gateway
logging.path=/data/java_log/jetty/${spring.application.name}/${spring.application.name}.log
spring.main.allow-bean-definition-overriding=true
#nacos config center
spring.cloud.nacos.config.server-addr=192.168.0.63:8868
spring.cloud.nacos.config.group=ARCHETYPE_GROUP
spring.cloud.nacos.config.prefix=${spring.application.name}
spring.profiles.active=dev
spring.cloud.nacos.config.file-extension=properties
#share config
spring.cloud.nacos.config.shared-configs[0].data-id=rest-microservice-share.properties
spring.cloud.nacos.config.shared-configs[0].group=ARCHETYPE_GROUP
spring.cloud.nacos.config.shared-configs[0].refresh=true
\ No newline at end of file
spring.application.name=glsx-rest-admin-gateway
logging.path=/data/java_log/jetty/${spring.application.name}/${spring.application.name}.log
spring.main.allow-bean-definition-overriding=true
#nacos配置中心
spring.cloud.nacos.config.server-addr=192.168.0.63:8848
spring.cloud.nacos.config.group=DEV_GROUP
spring.cloud.nacos.config.prefix=glsx-rest-admin-gateway
#spring.profiles.active=DEV
#spring.cloud.nacos.config.file-extension=properties
#微服务sentinel、zipkin、actuator等公共配置
spring.cloud.nacos.config.shared-configs[0].data-id=glsx-rest-microservice-share.properties
spring.cloud.nacos.config.shared-configs[0].group=DEV_GROUP
spring.cloud.nacos.config.shared-configs[0].refresh=true
\ No newline at end of file
......@@ -16,7 +16,6 @@
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-mybatis</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.12.RELEASE</version>
<version>2.6.11</version>
</parent>
<groupId>com.glsx</groupId>
......@@ -23,15 +23,17 @@
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<spring-cloud.version>Hoxton.SR12</spring-cloud.version>
<spring-cloud-alibaba.version>2.2.9.RELEASE</spring-cloud-alibaba.version>
<!-- 版本说明:https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E-->
<spring-cloud.version>2021.0.4</spring-cloud.version>
<spring-cloud-alibaba.version>2021.0.4.0</spring-cloud-alibaba.version>
<revision>2.0.0-SNAPSHOT</revision>
<!-- 本地发布服务器 -->
<!-- <local.nexus.snapshots.url>http://127.0.0.1:8081/repository/maven-snapshots/</local.nexus.snapshots.url>-->
<!-- <local.nexus.releases.url>http://127.0.0.1:8081/repository/maven-releases/</local.nexus.releases.url>-->
<!-- <local.nexus.snapshots.url>http://127.0.0.1:8081/repository/maven-snapshots/</local.nexus.snapshots.url>-->
<!-- <local.nexus.releases.url>http://127.0.0.1:8081/repository/maven-releases/</local.nexus.releases.url>-->
<local.nexus.snapshots.url>http://192.168.3.233/nexus/content/repositories/snapshots/</local.nexus.snapshots.url>
<local.nexus.snapshots.url>http://192.168.3.233/nexus/content/repositories/snapshots/
</local.nexus.snapshots.url>
<local.nexus.releases.url>http://192.168.3.233/nexus/content/repositories/releases/</local.nexus.releases.url>
</properties>
......
......@@ -138,6 +138,10 @@
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
......
......@@ -31,17 +31,14 @@
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-common</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-redis</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
......
......@@ -41,10 +41,6 @@
<artifactId>jakarta.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>com.netflix.ribbon</groupId>
<artifactId>ribbon-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
......
package com.glsx.plat.exception;
import com.glsx.plat.core.web.R;
import com.netflix.client.ClientException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.MDC;
......@@ -186,12 +185,6 @@ public class GlobalRExceptionHandler {
return R.error(e.getCode(), e.getMsg());
}
@ExceptionHandler(ClientException.class)
public R handleClientException(ClientException e) {
saveException(e, ExceptionLevel.fatal);
return R.error(e.getErrorCode(), e.getErrorMessage());
}
/**
* 未识别异常
*
......
......@@ -31,7 +31,6 @@
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-sentinel</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
......
......@@ -5,9 +5,9 @@ import feign.Contract;
import feign.Feign;
import feign.InvocationHandlerFactory;
import feign.Target;
import feign.hystrix.FallbackFactory;
import lombok.SneakyThrows;
import org.springframework.beans.BeansException;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.cloud.openfeign.FeignContext;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
......
......@@ -19,7 +19,7 @@ import org.springframework.context.annotation.Configuration;
* @author payu
*/
@Slf4j
//@Configuration
@Configuration
public class FeignErrorDecoder implements ErrorDecoder {
@Override
......
package com.glsx.plat.feign.fallback;
import feign.Target;
import feign.hystrix.FallbackFactory;
import lombok.AllArgsConstructor;
import org.springframework.cglib.proxy.Enhancer;
import org.springframework.cloud.openfeign.FallbackFactory;
@AllArgsConstructor
public class FunFallbackFactory<T> implements FallbackFactory<T> {
......
......@@ -18,7 +18,7 @@
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
<artifactId>spring-cloud-loadbalancer</artifactId>
</dependency>
<dependency>
<groupId>com.glsx</groupId>
......@@ -40,17 +40,14 @@
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-common</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-exception</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -22,7 +22,6 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
......
......@@ -9,13 +9,9 @@ import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
......@@ -90,7 +86,7 @@ public class RedisUtils {
if (key.length == 1) {
redisTemplate.delete(key[0]);
} else {
redisTemplate.delete(CollectionUtils.arrayToList(key));
redisTemplate.delete(Arrays.asList(key));
}
}
}
......
......@@ -17,13 +17,6 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<!--zipkin-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
......
......@@ -21,7 +21,6 @@
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger2.version}</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>org.mapstruct</groupId>
......
......@@ -31,7 +31,6 @@
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-exception</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!