JeecgBoot 2.4.6版本发布

This commit is contained in:
zhangdaiscott
2021-08-13 15:27:30 +08:00
parent 77ae4413ca
commit cd74b7f882
126 changed files with 3242 additions and 980 deletions

View File

@ -10,6 +10,6 @@ WORKDIR /jeecg-cloud-gateway
EXPOSE 9999
ADD ./target/jeecg-cloud-gateway-2.4.5.jar ./
ADD ./target/jeecg-cloud-gateway-2.4.6.jar ./
CMD sleep 10;java -Dfile.encoding=utf-8 -Djava.security.egd=file:/dev/./urandom -jar jeecg-cloud-gateway-2.4.5.jar
CMD sleep 10;java -Dfile.encoding=utf-8 -Djava.security.egd=file:/dev/./urandom -jar jeecg-cloud-gateway-2.4.6.jar

View File

@ -0,0 +1,7 @@
# 服务化改造手册
~~~
注意 :启动服务跨域问题处理
1、需要将common 模块的 WebMvcConfiguration corsFilter 注掉 后面做成注解切换
2、org.jeecg.config.shiro.filters.JwtFilter类的 65行跨域代码注释掉
~~~

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>jeecg-cloud-module</artifactId>
<groupId>org.jeecgframework.boot</groupId>
<version>2.4.5</version>
<version>2.4.6</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -27,6 +27,19 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<!--sentinel断路器依赖-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-sentinel-gateway</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-web-servlet</artifactId>
</dependency>
<!--Spring Webflux-->
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@ -0,0 +1,24 @@
package org.jeecg.filter;
import com.alibaba.csp.sentinel.adapter.servlet.CommonFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author Administrator
*/
@Configuration
public class SentinelFilterContextConfig {
@Bean
public FilterRegistrationBean sentinelFilterRegistration() {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(new CommonFilter());
registration.addUrlPatterns("/*");
// 入口资源关闭聚合
registration.addInitParameter(CommonFilter.WEB_CONTEXT_UNIFY, "false");
registration.setName("sentinelFilter");
registration.setOrder(1);
return registration;
}
}

View File

@ -1,5 +1,6 @@
package org.jeecg.handler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.gateway.route.RouteLocator;
@ -13,6 +14,7 @@ import java.util.*;
* 聚合各个服务的swagger接口
*/
@Component
@Slf4j
public class MySwaggerResourceProvider implements SwaggerResourcesProvider {
/**
* swagger2默认的url后缀
@ -51,6 +53,7 @@ public class MySwaggerResourceProvider implements SwaggerResourcesProvider {
String url = "/" + instance.toLowerCase() + SWAGGER2URL;
if (!dealed.contains(url)) {
dealed.add(url);
log.info(" Gateway add SwaggerResource: {}",url);
SwaggerResource swaggerResource = new SwaggerResource();
swaggerResource.setUrl(url);
swaggerResource.setSwaggerVersion("2.0");

View File

@ -0,0 +1,38 @@
package org.jeecg.handler;
import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.BlockRequestHandler;
import com.alibaba.csp.sentinel.transport.config.TransportConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.commons.util.InetUtils;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.server.ServerResponse;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
import javax.annotation.PostConstruct;
/**
* 自定义限流返回信息
* @author Administrator
*/
@Slf4j
@Component
public class SentinelBlockRequestHandler implements BlockRequestHandler {
@Autowired
private InetUtils inetUtils;
@PostConstruct
public void doInit() {
System.setProperty(TransportConfig.HEARTBEAT_CLIENT_IP, inetUtils.findFirstNonLoopbackAddress().getHostAddress());
}
@Override
public Mono<ServerResponse> handleRequest(ServerWebExchange exchange, Throwable ex) {
String resultString = "{\"code\":403,\"message\":\"服务开启限流保护,请稍后再试!\"}";
return ServerResponse.status(HttpStatus.TOO_MANY_REQUESTS).contentType(MediaType.APPLICATION_JSON_UTF8).body(BodyInserters.fromObject(resultString));
}
}

View File

@ -4,6 +4,13 @@ spring:
application:
name: jeecg-gateway
cloud:
#Sentinel配置
sentinel:
web-context-unify: false
transport:
dashboard: localhost:8087
# 懒加载Sentinel Dashboard菜单
eager: false
gateway:
discovery:
locator: