mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2026-01-03 20:35:29 +08:00
微服务重大升级说明(暂时只升级后台3.4.0)
-升级Spring Cloud Alibaba 2021.0.1.0,使用 spring.config.import 方式引入nacos配置 -拆分jeecg-boot-starter出来,使用独立项目维护
This commit is contained in:
@ -10,6 +10,6 @@ WORKDIR /jeecg-cloud-gateway
|
||||
|
||||
EXPOSE 9999
|
||||
|
||||
ADD ./target/jeecg-cloud-gateway-3.3.0.jar ./
|
||||
ADD ./target/jeecg-cloud-gateway-3.4.0.jar ./
|
||||
|
||||
CMD sleep 50;java -Dfile.encoding=utf-8 -Djava.security.egd=file:/dev/./urandom -jar jeecg-cloud-gateway-3.3.0.jar
|
||||
CMD sleep 50;java -Dfile.encoding=utf-8 -Djava.security.egd=file:/dev/./urandom -jar jeecg-cloud-gateway-3.4.0.jar
|
||||
@ -1,7 +1,3 @@
|
||||
# 服务化改造手册
|
||||
http://localhost:9999
|
||||
|
||||
~~~
|
||||
注意 :启动服务跨域问题处理
|
||||
1、需要将common 模块的 WebMvcConfiguration corsFilter 注掉 后面做成注解切换
|
||||
2、org.jeecg.config.shiro.filters.JwtFilter类的 65行,跨域代码注释掉
|
||||
~~~
|
||||
提示:在未启动服务实例情况下,看的接口文档为空
|
||||
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>jeecg-cloud-module</artifactId>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.4.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>jeecg-cloud-gateway</artifactId>
|
||||
|
||||
@ -31,8 +31,8 @@ public class JeecgGatewayApplication implements CommandLineRunner {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ConfigurableApplicationContext applicationContext = SpringApplication.run(JeecgGatewayApplication.class, args);
|
||||
String userName = applicationContext.getEnvironment().getProperty("jeecg.test");
|
||||
System.err.println("user name :" +userName);
|
||||
//String userName = applicationContext.getEnvironment().getProperty("jeecg.test");
|
||||
//System.err.println("user name :" +userName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -28,7 +28,7 @@ public class GatewayRoutersConfig {
|
||||
this.serverAddr = serverAddr;
|
||||
}
|
||||
|
||||
@Value("${spring.cloud.nacos.discovery.namespace}")
|
||||
@Value("${spring.cloud.nacos.discovery.namespace:#{null}}")
|
||||
public void setNamespace(String namespace) {
|
||||
this.namespace = namespace;
|
||||
}
|
||||
@ -48,12 +48,12 @@ public class GatewayRoutersConfig {
|
||||
this.dataType = dataType;
|
||||
}
|
||||
|
||||
@Value("${spring.cloud.nacos.config.username}")
|
||||
@Value("${spring.cloud.nacos.config.username:#{null}}")
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
@Value("${spring.cloud.nacos.config.password}")
|
||||
@Value("${spring.cloud.nacos.config.password:#{null}}")
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@ -339,9 +339,15 @@ public class DynamicRouteLoader implements ApplicationEventPublisherAware {
|
||||
try {
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("serverAddr", gatewayRoutersConfig.getServerAddr());
|
||||
properties.setProperty("namespace", gatewayRoutersConfig.getNamespace());
|
||||
properties.setProperty("username", gatewayRoutersConfig.getUsername());
|
||||
properties.setProperty("password", gatewayRoutersConfig.getPassword());
|
||||
if(StringUtils.isNotBlank(gatewayRoutersConfig.getNamespace())){
|
||||
properties.setProperty("namespace", gatewayRoutersConfig.getNamespace());
|
||||
}
|
||||
if(StringUtils.isNotBlank( gatewayRoutersConfig.getUsername())){
|
||||
properties.setProperty("username", gatewayRoutersConfig.getUsername());
|
||||
}
|
||||
if(StringUtils.isNotBlank(gatewayRoutersConfig.getPassword())){
|
||||
properties.setProperty("password", gatewayRoutersConfig.getPassword());
|
||||
}
|
||||
return configService = NacosFactory.createConfigService(properties);
|
||||
} catch (Exception e) {
|
||||
log.error("创建ConfigService异常", e);
|
||||
|
||||
@ -1,13 +1,32 @@
|
||||
server:
|
||||
port: 9999
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: jeecg-gateway
|
||||
main:
|
||||
#循环依赖默认情况下已经被禁止了
|
||||
allow-circular-references: true
|
||||
allow-bean-definition-overriding: true
|
||||
config:
|
||||
import:
|
||||
- optional:nacos:${spring.application.name}-@profile.name@.yaml
|
||||
cloud:
|
||||
nacos:
|
||||
config:
|
||||
server-addr: @config.server-addr@
|
||||
discovery:
|
||||
server-addr: ${spring.cloud.nacos.config.server-addr}
|
||||
gateway:
|
||||
discovery:
|
||||
locator:
|
||||
enabled: true
|
||||
globalcors:
|
||||
cors-configurations:
|
||||
'[/**]':
|
||||
allowCredentials: true
|
||||
#springboot2.4后需用allowedOriginPatterns
|
||||
allowedOriginPatterns: "*"
|
||||
allowedMethods: "*"
|
||||
allowedHeaders: "*"
|
||||
#Sentinel配置
|
||||
sentinel:
|
||||
transport:
|
||||
@ -79,36 +98,4 @@ spring:
|
||||
dataId: ${spring.application.name}-api-rules
|
||||
groupId: SENTINEL_GROUP
|
||||
rule-type: gw-api-group
|
||||
data-type: json
|
||||
gateway:
|
||||
discovery:
|
||||
locator:
|
||||
enabled: true
|
||||
globalcors:
|
||||
cors-configurations:
|
||||
'[/**]':
|
||||
allowCredentials: true
|
||||
#springboot2.4后需用allowedOriginPatterns
|
||||
allowedOriginPatterns: "*"
|
||||
allowedMethods: "*"
|
||||
allowedHeaders: "*"
|
||||
# httpclient:
|
||||
# connect-timeout: 1000
|
||||
# response-timeout: 5s
|
||||
# # Nacos的yml方式路由配置(默认注释掉,采用数据库加载)
|
||||
# - id: jeecg-demo
|
||||
# uri: lb://jeecg-demo
|
||||
# predicates:
|
||||
# - Path=/mock/**,/test/**,/bigscreen/template1/**,/bigscreen/template2/**
|
||||
# - id: jeecg-system
|
||||
# uri: lb://jeecg-system
|
||||
# predicates:
|
||||
# - Path=/sys/**,/eoa/**,/v1/**,/joa/**,/online/**,/bigscreen/**,/jmreport/**,/desform/**,/act/**,/plug-in/**,/generic/**
|
||||
# - id: jeecg-system-websocket
|
||||
# uri: lb:ws://jeecg-system
|
||||
# predicates:
|
||||
# - Path=/websocket/**,/eoaSocket/**,/newsWebsocket/**
|
||||
# - id: jeecg-demo-websocket
|
||||
# uri: lb:ws://jeecg-demo
|
||||
# predicates:
|
||||
# - Path=/vxeSocket/**
|
||||
data-type: json
|
||||
Reference in New Issue
Block a user