spring boot 3.06
This commit is contained in:
17
pom.xml
17
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>3.0.5</version>
|
<version>3.0.6</version>
|
||||||
<relativePath /> <!-- lookup parent from repository -->
|
<relativePath /> <!-- lookup parent from repository -->
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>com.flagnote</groupId>
|
<groupId>com.flagnote</groupId>
|
||||||
@@ -20,7 +20,8 @@
|
|||||||
<maven.compiler.target>17</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
<maven.compiler.compilerVersion>17</maven.compiler.compilerVersion>
|
<maven.compiler.compilerVersion>17</maven.compiler.compilerVersion>
|
||||||
<spring-cloud.version>2022.0.2</spring-cloud.version>
|
<spring-cloud.version>2022.0.2</spring-cloud.version>
|
||||||
<docker.image.prefix>flagnote</docker.image.prefix>
|
<docker.repostory>registry.openif.com:5000</docker.repostory>
|
||||||
|
<docker.registry.name>flagnote</docker.registry.name>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -56,7 +57,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-all</artifactId>
|
<artifactId>hutool-all</artifactId>
|
||||||
<version>5.7.22</version>
|
<version>5.8.18</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
@@ -117,11 +118,15 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.spotify</groupId>
|
<groupId>com.spotify</groupId>
|
||||||
<artifactId>docker-maven-plugin</artifactId>
|
<artifactId>docker-maven-plugin</artifactId>
|
||||||
|
<version>1.2.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<googleContainerRegistryEnabled>false</googleContainerRegistryEnabled>
|
<serverId>docker-openif</serverId>
|
||||||
<dockerHost>http://rancher:42375</dockerHost>
|
<registryUrl>http://${docker.repository}</registryUrl>
|
||||||
|
<pushImage>true</pushImage>
|
||||||
|
<dockerHost>http://144.34.221.20:42375</dockerHost>
|
||||||
<imageName>
|
<imageName>
|
||||||
${docker.image.prefix}/${project.artifactId}:${project.version}</imageName>
|
${docker.repostory}/${docker.registry.name}/${project.artifactId}:${project.version}
|
||||||
|
</imageName>
|
||||||
<dockerDirectory>src/main/docker</dockerDirectory>
|
<dockerDirectory>src/main/docker</dockerDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import java.util.concurrent.ThreadLocalRandom;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.springframework.beans.factory.ObjectProvider;
|
import org.springframework.beans.factory.ObjectProvider;
|
||||||
import org.springframework.cloud.client.ServiceInstance;
|
import org.springframework.cloud.client.ServiceInstance;
|
||||||
import org.springframework.cloud.client.loadbalancer.DefaultResponse;
|
import org.springframework.cloud.client.loadbalancer.DefaultResponse;
|
||||||
@@ -16,7 +14,6 @@ import org.springframework.cloud.client.loadbalancer.RequestData;
|
|||||||
import org.springframework.cloud.client.loadbalancer.RequestDataContext;
|
import org.springframework.cloud.client.loadbalancer.RequestDataContext;
|
||||||
import org.springframework.cloud.client.loadbalancer.Response;
|
import org.springframework.cloud.client.loadbalancer.Response;
|
||||||
import org.springframework.cloud.loadbalancer.core.NoopServiceInstanceListSupplier;
|
import org.springframework.cloud.loadbalancer.core.NoopServiceInstanceListSupplier;
|
||||||
import org.springframework.cloud.loadbalancer.core.RandomLoadBalancer;
|
|
||||||
import org.springframework.cloud.loadbalancer.core.ReactorServiceInstanceLoadBalancer;
|
import org.springframework.cloud.loadbalancer.core.ReactorServiceInstanceLoadBalancer;
|
||||||
import org.springframework.cloud.loadbalancer.core.SelectedInstanceCallback;
|
import org.springframework.cloud.loadbalancer.core.SelectedInstanceCallback;
|
||||||
import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
|
import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ import org.springframework.core.env.Environment;
|
|||||||
//@Configuration 必须注释掉
|
//@Configuration 必须注释掉
|
||||||
public class BkrLoadBalancerConfiguration {
|
public class BkrLoadBalancerConfiguration {
|
||||||
@Bean
|
@Bean
|
||||||
public ReactorLoadBalancer<ServiceInstance> reactorServiceInstanceLoadBalancer(Environment environment, LoadBalancerClientFactory loadBalancerClientFactory) {
|
public ReactorLoadBalancer<ServiceInstance> reactorServiceInstanceLoadBalancer(Environment environment,
|
||||||
|
LoadBalancerClientFactory loadBalancerClientFactory) {
|
||||||
String name = environment.getProperty(LoadBalancerClientFactory.PROPERTY_NAME);
|
String name = environment.getProperty(LoadBalancerClientFactory.PROPERTY_NAME);
|
||||||
return new BizKeyLoadBalancerClient(loadBalancerClientFactory.getLazyProvider(name, ServiceInstanceListSupplier.class), name);
|
return new BizKeyLoadBalancerClient(
|
||||||
|
loadBalancerClientFactory.getLazyProvider(name, ServiceInstanceListSupplier.class), name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package com.flagnote.gateway.config;
|
package com.flagnote.gateway.config;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.web.cors.CorsConfiguration;
|
import org.springframework.web.cors.CorsConfiguration;
|
||||||
import org.springframework.web.cors.reactive.CorsWebFilter;
|
import org.springframework.web.cors.reactive.CorsWebFilter;
|
||||||
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
|
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
|
||||||
@@ -29,8 +27,7 @@ public class GwCorsFilter {
|
|||||||
config.addAllowedMethod("DELETE");
|
config.addAllowedMethod("DELETE");
|
||||||
config.addAllowedMethod("PATCH");
|
config.addAllowedMethod("PATCH");
|
||||||
|
|
||||||
UrlBasedCorsConfigurationSource source =
|
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());
|
||||||
new UrlBasedCorsConfigurationSource(new PathPatternParser());
|
|
||||||
source.registerCorsConfiguration("/**", config);
|
source.registerCorsConfiguration("/**", config);
|
||||||
|
|
||||||
return new CorsWebFilter(source);
|
return new CorsWebFilter(source);
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import org.springframework.web.server.ServerWebExchange;
|
|||||||
|
|
||||||
import com.flagnote.gateway.utils.BizKeyUtils;
|
import com.flagnote.gateway.utils.BizKeyUtils;
|
||||||
|
|
||||||
import cn.hutool.json.JSON;
|
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
@@ -41,7 +40,6 @@ public class ValidateNoteCipherFilter implements GatewayFilter, Ordered {
|
|||||||
return exchange.getResponse().setComplete();
|
return exchange.getResponse().setComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return chain.filter(exchange);
|
return chain.filter(exchange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
|||||||
import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
|
import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
import org.springframework.web.server.ServerWebExchange;
|
||||||
|
|
||||||
@@ -33,7 +32,8 @@ public class ValidateNoteKeyFilter implements GatewayFilter, Ordered {
|
|||||||
|
|
||||||
if (!BizKeyUtils.validateKey(noteKey)) {
|
if (!BizKeyUtils.validateKey(noteKey)) {
|
||||||
NoteMeta meta = new NoteMeta();
|
NoteMeta meta = new NoteMeta();
|
||||||
DataBuffer dataBuffer = exchange.getResponse().bufferFactory().wrap(JsonUtils.toJson(meta).getBytes(StandardCharsets.UTF_8));
|
DataBuffer dataBuffer = exchange.getResponse().bufferFactory()
|
||||||
|
.wrap(JsonUtils.toJson(meta).getBytes(StandardCharsets.UTF_8));
|
||||||
return exchange.getResponse().writeWith(Flux.just(dataBuffer));
|
return exchange.getResponse().writeWith(Flux.just(dataBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,13 @@
|
|||||||
package com.flagnote.gateway.filter.factory;
|
package com.flagnote.gateway.filter.factory;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cloud.gateway.filter.GatewayFilter;
|
import org.springframework.cloud.gateway.filter.GatewayFilter;
|
||||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
|
||||||
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
|
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
|
||||||
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory.NameConfig;
|
|
||||||
import org.springframework.cloud.gateway.support.GatewayToStringStyler;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
|
||||||
|
|
||||||
import com.flagnote.gateway.filter.ValidateNoteCipherFilter;
|
import com.flagnote.gateway.filter.ValidateNoteCipherFilter;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import reactor.core.publisher.Mono;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@@ -26,7 +17,6 @@ public class ValidateNoteCipherGatewayFilterFactory
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ValidateNoteCipherFilter validateNoteCipherFilter;
|
private ValidateNoteCipherFilter validateNoteCipherFilter;
|
||||||
|
|
||||||
|
|
||||||
public ValidateNoteCipherGatewayFilterFactory() {
|
public ValidateNoteCipherGatewayFilterFactory() {
|
||||||
super(NameConfig.class);
|
super(NameConfig.class);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,13 @@
|
|||||||
package com.flagnote.gateway.filter.factory;
|
package com.flagnote.gateway.filter.factory;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cloud.gateway.filter.GatewayFilter;
|
import org.springframework.cloud.gateway.filter.GatewayFilter;
|
||||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
|
||||||
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
|
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
|
||||||
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory.NameConfig;
|
|
||||||
import org.springframework.cloud.gateway.support.GatewayToStringStyler;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
|
||||||
|
|
||||||
import com.flagnote.gateway.filter.ValidateNoteKeyFilter;
|
import com.flagnote.gateway.filter.ValidateNoteKeyFilter;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import reactor.core.publisher.Mono;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@@ -26,7 +17,6 @@ public class ValidateNoteKeyGatewayFilterFactory
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ValidateNoteKeyFilter validateNoteKeyFilter;
|
private ValidateNoteKeyFilter validateNoteKeyFilter;
|
||||||
|
|
||||||
|
|
||||||
public ValidateNoteKeyGatewayFilterFactory() {
|
public ValidateNoteKeyGatewayFilterFactory() {
|
||||||
super(NameConfig.class);
|
super(NameConfig.class);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,6 @@ public class BizKeyUtils {
|
|||||||
return md5(key + "#" + MIX_STRING + "#" + initTime).equals(cipher);
|
return md5(key + "#" + MIX_STRING + "#" + initTime).equals(cipher);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String getSecretKey(String key, String password) {
|
public static String getSecretKey(String key, String password) {
|
||||||
return md5(key + md5(MIX_STRING + password));
|
return md5(key + md5(MIX_STRING + password));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,12 +79,9 @@ public class JsonUtils {
|
|||||||
return parse(json, null, type);
|
return parse(json, null, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* json => 对象处理方法
|
* json => 对象处理方法 <br>
|
||||||
* <br>
|
* 参数clazz和type必须一个为null,另一个不为null <br>
|
||||||
* 参数clazz和type必须一个为null,另一个不为null
|
|
||||||
* <br>
|
|
||||||
* 此方法不对外暴露,访问权限为private
|
* 此方法不对外暴露,访问权限为private
|
||||||
*
|
*
|
||||||
* @param json 源json串
|
* @param json 源json串
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import java.io.Serializable;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class NoteMeta implements Serializable {/**
|
public class NoteMeta implements Serializable {
|
||||||
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -8234044213813670440L;
|
private static final long serialVersionUID = -8234044213813670440L;
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ spring:
|
|||||||
config:
|
config:
|
||||||
name: flagnote-gateway
|
name: flagnote-gateway
|
||||||
profile: prd
|
profile: prd
|
||||||
uri: http://flagnote-config-01:8080/flagnote-config,http://flagnote-config-02:8080/flagnote-config
|
uri: http://flagnote-config-01:8080/flagnote-config
|
||||||
config:
|
config:
|
||||||
import: optional:configserver:http://flagnote-config-01:8080/,optional:configserver:http://flagnote-config-02:8080/
|
import: optional:configserver:http://flagnote-config-01:8080/
|
||||||
|
|
||||||
|
|||||||
35
src/main/resources/logback-spring.xml
Normal file
35
src/main/resources/logback-spring.xml
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<springProperty scope="context" name="logPath" source="logback.logPath"/>
|
||||||
|
<property name="pattern" value="[%date{yyyy-MM-dd HH:mm:ss.SSS}] %X{logthreadId} %-5level %logger{80} %method %line - %msg%n"/>
|
||||||
|
<property name="charsetEncoding" value="UTF-8"/>
|
||||||
|
<property name="LOG_HOME" value="${logPath}"/>
|
||||||
|
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>${pattern}</pattern>
|
||||||
|
<charset>${charsetEncoding}</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
<appender name="infoLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<append>true</append>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${pattern}</pattern>
|
||||||
|
<charset>${charsetEncoding}</charset>
|
||||||
|
</encoder>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>
|
||||||
|
${LOG_HOME}${file.separator}%d{yyMMdd}_info_%i.log
|
||||||
|
</fileNamePattern>
|
||||||
|
<maxHistory>30</maxHistory>
|
||||||
|
<maxFileSize>20MB</maxFileSize>
|
||||||
|
</rollingPolicy>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||||
|
<level>INFO</level>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="console"/>
|
||||||
|
<appender-ref ref="infoLog"/>
|
||||||
|
</root>
|
||||||
|
</configuration>
|
||||||
Reference in New Issue
Block a user