mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
2.0
This commit is contained in:
@@ -22,18 +22,20 @@
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<okhttp.version>3.11.0</okhttp.version>
|
||||
<!-- springboot for nacos,https://nacos.io/zh-cn/docs/quick-start-spring-boot.html -->
|
||||
<nacos-spring-boot-starter.version>0.2.3</nacos-spring-boot-starter.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.boot</groupId>
|
||||
<artifactId>nacos-config-spring-boot-starter</artifactId>
|
||||
<version>0.2.3</version>
|
||||
<version>${nacos-spring-boot-starter.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.boot</groupId>
|
||||
<artifactId>nacos-discovery-spring-boot-starter</artifactId>
|
||||
<version>0.2.3</version>
|
||||
<version>${nacos-spring-boot-starter.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- easyopen starter -->
|
||||
|
@@ -30,6 +30,7 @@
|
||||
<commons-codec.version>1.11</commons-codec.version>
|
||||
<validation-api.version>2.0.1.Final</validation-api.version>
|
||||
<hibernate-validator.version>6.0.13.Final</hibernate-validator.version>
|
||||
<spring-cloud-alibaba-nacos.version>0.9.0.RELEASE</spring-cloud-alibaba-nacos.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
@@ -57,14 +58,14 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-nacos-discovery</artifactId>
|
||||
<version>0.9.0.RELEASE</version>
|
||||
<version>${spring-cloud-alibaba-nacos.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
<version>0.9.0.RELEASE</version>
|
||||
<artifactId>spring-cloud-alibaba-nacos-config</artifactId>
|
||||
<version>${spring-cloud-alibaba-nacos.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
@@ -20,14 +20,6 @@
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
@@ -52,6 +44,17 @@
|
||||
</dependency>
|
||||
|
||||
<!-- optional -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-nacos-discovery</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-nacos-config</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.gitee.sop.gatewaycommon.manager;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.nacos.api.annotation.NacosInjected;
|
||||
import com.alibaba.nacos.api.config.ConfigService;
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
@@ -11,7 +12,6 @@ import com.gitee.sop.gatewaycommon.bean.ServiceRouteInfo;
|
||||
import com.gitee.sop.gatewaycommon.bean.TargetRoute;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.alibaba.nacos.NacosConfigProperties;
|
||||
import org.springframework.cloud.alibaba.nacos.NacosDiscoveryProperties;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -41,8 +41,14 @@ public class ServiceRoutesLoader<T extends TargetRoute> {
|
||||
@Autowired
|
||||
private NacosDiscoveryProperties nacosDiscoveryProperties;
|
||||
|
||||
@Autowired
|
||||
private NacosConfigProperties nacosConfigProperties;
|
||||
// @NacosInjected
|
||||
// private NamingService namingService;
|
||||
|
||||
// @Autowired
|
||||
// private NacosConfigProperties nacosConfigProperties;
|
||||
|
||||
@NacosInjected
|
||||
private ConfigService configService;
|
||||
|
||||
@Autowired
|
||||
private BaseRouteCache<T> baseRouteCache;
|
||||
@@ -74,7 +80,7 @@ public class ServiceRoutesLoader<T extends TargetRoute> {
|
||||
}
|
||||
// subscribe
|
||||
String thisServiceId = nacosDiscoveryProperties.getService();
|
||||
ConfigService configService = nacosConfigProperties.configServiceInstance();
|
||||
// ConfigService configService = nacosConfigProperties.configServiceInstance();
|
||||
for (ServiceInfo serviceInfo : subscribes) {
|
||||
String serviceName = serviceInfo.getName();
|
||||
// 如果是本机服务,跳过
|
||||
|
@@ -21,11 +21,14 @@
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-nacos-discovery</artifactId>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>27.1-jre</version>
|
||||
</dependency>
|
||||
|
||||
<!-- optional -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
@@ -48,12 +51,11 @@
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>1.5.21</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot</artifactId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@@ -18,6 +18,10 @@
|
||||
<java.version>1.8</java.version>
|
||||
<dubbo.version>2.6.5</dubbo.version>
|
||||
<spring-cloud.version>Greenwich.RELEASE</spring-cloud.version>
|
||||
<!-- nacos spring cloud版本号 -->
|
||||
<spring-cloud-alibaba-nacos.version>0.9.0.RELEASE</spring-cloud-alibaba-nacos.version>
|
||||
<!-- nacos客户端版本号 -->
|
||||
<nacos-client.version>1.1.0</nacos-client.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -38,14 +42,6 @@
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- 注册中心【只能用一个,不用的注释掉】 -->
|
||||
<!-- 使用eureka注册中心
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
<!-- 使用nacos注册中心
|
||||
版本 0.2.x.RELEASE 对应的是 Spring Boot 2.x 版本,版本 0.1.x.RELEASE 对应的是 Spring Boot 1.x 版本。
|
||||
https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-alibaba-nacos-discovery
|
||||
@@ -53,9 +49,13 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
<version>0.2.2.RELEASE</version>
|
||||
<version>${spring-cloud-alibaba-nacos.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-client</artifactId>
|
||||
<version>${nacos-client.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 注册中心end -->
|
||||
|
||||
|
||||
|
@@ -18,6 +18,10 @@
|
||||
<java.version>1.8</java.version>
|
||||
<dubbo.version>2.6.5</dubbo.version>
|
||||
<spring-cloud.version>Greenwich.RELEASE</spring-cloud.version>
|
||||
<!-- nacos spring cloud版本号 -->
|
||||
<spring-cloud-alibaba-nacos.version>0.9.0.RELEASE</spring-cloud-alibaba-nacos.version>
|
||||
<!-- nacos客户端版本号 -->
|
||||
<nacos-client.version>1.1.0</nacos-client.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -32,14 +36,6 @@
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 注册中心【只能用一个,不用的注释掉】 -->
|
||||
<!-- 使用eureka注册中心
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
<!-- 使用nacos注册中心
|
||||
版本 0.2.x.RELEASE 对应的是 Spring Boot 2.x 版本,版本 0.1.x.RELEASE 对应的是 Spring Boot 1.x 版本。
|
||||
https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-alibaba-nacos-discovery
|
||||
@@ -47,20 +43,13 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
<version>0.2.2.RELEASE</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-client</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<version>${spring-cloud-alibaba-nacos.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-client</artifactId>
|
||||
<version>1.1.0</version>
|
||||
<version>${nacos-client.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 注册中心end -->
|
||||
|
||||
<dependency>
|
||||
@@ -84,12 +73,6 @@
|
||||
<artifactId>netty-all</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>25.1-jre</version>
|
||||
</dependency>
|
||||
|
||||
<!-- swagger2 -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
|
@@ -17,6 +17,12 @@
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<spring-cloud.version>Greenwich.RELEASE</spring-cloud.version>
|
||||
<!-- nacos spring cloud版本号 -->
|
||||
<spring-cloud-alibaba-nacos.version>0.9.0.RELEASE</spring-cloud-alibaba-nacos.version>
|
||||
<!-- nacos客户端版本号 -->
|
||||
<nacos-client.version>1.1.0</nacos-client.version>
|
||||
<!-- springboot for nacos,https://nacos.io/zh-cn/docs/quick-start-spring-boot.html -->
|
||||
<nacos-spring-boot-starter.version>0.2.3</nacos-spring-boot-starter.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -37,23 +43,6 @@
|
||||
</dependency>
|
||||
<!-- ↑↑↑ 使用spring cloud zuul ↑↑↑ -->
|
||||
|
||||
|
||||
<!-- ↓↓↓ 使用spring cloud gateway,处于beta阶段,推荐使用zuul ↓↓↓
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-gateway</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
-->
|
||||
<!-- ↑↑↑ 使用spring cloud gateway ↑↑↑ -->
|
||||
|
||||
<dependency>
|
||||
<groupId>net.oschina.durcframework</groupId>
|
||||
<artifactId>fastmybatis-spring-boot-starter</artifactId>
|
||||
@@ -72,22 +61,25 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
<version>0.2.2.RELEASE</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-client</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<version>${spring-cloud-alibaba-nacos.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-client</artifactId>
|
||||
<version>1.1.0</version>
|
||||
<version>${nacos-client.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 注册中心end -->
|
||||
|
||||
<!--
|
||||
这里依赖springboot版本,非cloud版本。
|
||||
如果依赖了spring-cloud-starter-alibaba-nacos-config,需要额外配置一个bootstrap.properties
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.boot</groupId>
|
||||
<artifactId>nacos-config-spring-boot-starter</artifactId>
|
||||
<version>${nacos-spring-boot-starter.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- test -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.gitee.sop.gateway.manager;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.nacos.api.annotation.NacosInjected;
|
||||
import com.alibaba.nacos.api.config.ConfigService;
|
||||
import com.alibaba.nacos.api.config.listener.AbstractListener;
|
||||
import com.gitee.fastmybatis.core.query.Query;
|
||||
@@ -17,7 +18,6 @@ import com.google.common.collect.Sets;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.alibaba.nacos.NacosConfigProperties;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
@@ -49,8 +49,8 @@ public class DbEnvGrayManager extends DefaultEnvGrayManager {
|
||||
@Autowired
|
||||
private ConfigGrayInstanceMapper configGrayInstanceMapper;
|
||||
|
||||
@Autowired
|
||||
private NacosConfigProperties nacosConfigProperties;
|
||||
@NacosInjected
|
||||
private ConfigService configService;
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
@@ -100,7 +100,6 @@ public class DbEnvGrayManager extends DefaultEnvGrayManager {
|
||||
|
||||
@PostConstruct
|
||||
protected void after() throws Exception {
|
||||
ConfigService configService = nacosConfigProperties.configServiceInstance();
|
||||
configService.addListener(NacosConfigs.DATA_ID_GRAY, NacosConfigs.GROUP_CHANNEL, new AbstractListener() {
|
||||
@Override
|
||||
public void receiveConfigInfo(String configInfo) {
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.gitee.sop.gateway.manager;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.nacos.api.annotation.NacosInjected;
|
||||
import com.alibaba.nacos.api.config.ConfigService;
|
||||
import com.alibaba.nacos.api.config.listener.AbstractListener;
|
||||
import com.gitee.sop.gateway.mapper.IPBlacklistMapper;
|
||||
@@ -10,7 +11,6 @@ import com.gitee.sop.gatewaycommon.manager.DefaultIPBlacklistManager;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.alibaba.nacos.NacosConfigProperties;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
@@ -28,8 +28,8 @@ public class DbIPBlacklistManager extends DefaultIPBlacklistManager {
|
||||
@Autowired
|
||||
private IPBlacklistMapper ipBlacklistMapper;
|
||||
|
||||
@Autowired
|
||||
private NacosConfigProperties nacosConfigProperties;
|
||||
@NacosInjected
|
||||
private ConfigService configService;
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
@@ -41,7 +41,6 @@ public class DbIPBlacklistManager extends DefaultIPBlacklistManager {
|
||||
|
||||
@PostConstruct
|
||||
protected void after() throws Exception {
|
||||
ConfigService configService = nacosConfigProperties.configServiceInstance();
|
||||
configService.addListener(NacosConfigs.DATA_ID_IP_BLACKLIST, NacosConfigs.GROUP_CHANNEL, new AbstractListener() {
|
||||
@Override
|
||||
public void receiveConfigInfo(String configInfo) {
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.gitee.sop.gateway.manager;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.nacos.api.annotation.NacosInjected;
|
||||
import com.alibaba.nacos.api.config.ConfigService;
|
||||
import com.alibaba.nacos.api.config.listener.AbstractListener;
|
||||
import com.gitee.sop.gateway.entity.IsvDetailDTO;
|
||||
@@ -13,7 +14,6 @@ import com.gitee.sop.gatewaycommon.secret.CacheIsvManager;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.alibaba.nacos.NacosConfigProperties;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
@@ -29,8 +29,8 @@ public class DbIsvManager extends CacheIsvManager {
|
||||
@Autowired
|
||||
private IsvInfoMapper isvInfoMapper;
|
||||
|
||||
@Autowired
|
||||
private NacosConfigProperties nacosConfigProperties;
|
||||
@NacosInjected
|
||||
private ConfigService configService;
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
@@ -47,7 +47,6 @@ public class DbIsvManager extends CacheIsvManager {
|
||||
protected void after() throws Exception {
|
||||
ApiConfig.getInstance().setIsvManager(this);
|
||||
|
||||
ConfigService configService = nacosConfigProperties.configServiceInstance();
|
||||
configService.addListener(NacosConfigs.DATA_ID_ISV, NacosConfigs.GROUP_CHANNEL, new AbstractListener() {
|
||||
@Override
|
||||
public void receiveConfigInfo(String configInfo) {
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.gitee.sop.gateway.manager;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.nacos.api.annotation.NacosInjected;
|
||||
import com.alibaba.nacos.api.config.ConfigService;
|
||||
import com.alibaba.nacos.api.config.listener.AbstractListener;
|
||||
import com.gitee.fastmybatis.core.query.Query;
|
||||
@@ -18,7 +19,6 @@ import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.alibaba.nacos.NacosConfigProperties;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -54,8 +54,8 @@ public class DbIsvRoutePermissionManager extends DefaultIsvRoutePermissionManage
|
||||
@Autowired
|
||||
IsvInfoMapper isvInfoMapper;
|
||||
|
||||
@Autowired
|
||||
private NacosConfigProperties nacosConfigProperties;
|
||||
@NacosInjected
|
||||
private ConfigService configService;
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
@@ -130,7 +130,6 @@ public class DbIsvRoutePermissionManager extends DefaultIsvRoutePermissionManage
|
||||
|
||||
@PostConstruct
|
||||
protected void after() throws Exception {
|
||||
ConfigService configService = nacosConfigProperties.configServiceInstance();
|
||||
configService.addListener(NacosConfigs.DATA_ID_ROUTE_PERMISSION, NacosConfigs.GROUP_CHANNEL, new AbstractListener() {
|
||||
@Override
|
||||
public void receiveConfigInfo(String configInfo) {
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.gitee.sop.gateway.manager;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.nacos.api.annotation.NacosInjected;
|
||||
import com.alibaba.nacos.api.config.ConfigService;
|
||||
import com.alibaba.nacos.api.config.listener.AbstractListener;
|
||||
import com.gitee.fastmybatis.core.query.Query;
|
||||
@@ -12,7 +13,6 @@ import com.gitee.sop.gatewaycommon.manager.DefaultLimitConfigManager;
|
||||
import com.gitee.sop.gatewaycommon.util.MyBeanUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.alibaba.nacos.NacosConfigProperties;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -32,8 +32,8 @@ public class DbLimitConfigManager extends DefaultLimitConfigManager {
|
||||
@Autowired
|
||||
Environment environment;
|
||||
|
||||
@Autowired
|
||||
private NacosConfigProperties nacosConfigProperties;
|
||||
@NacosInjected
|
||||
private ConfigService configService;
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
@@ -53,7 +53,6 @@ public class DbLimitConfigManager extends DefaultLimitConfigManager {
|
||||
|
||||
@PostConstruct
|
||||
protected void after() throws Exception {
|
||||
ConfigService configService = nacosConfigProperties.configServiceInstance();
|
||||
configService.addListener(NacosConfigs.DATA_ID_LIMIT_CONFIG, NacosConfigs.GROUP_CHANNEL, new AbstractListener() {
|
||||
@Override
|
||||
public void receiveConfigInfo(String configInfo) {
|
||||
|
@@ -1,21 +1,21 @@
|
||||
package com.gitee.sop.gateway.manager;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.nacos.api.annotation.NacosInjected;
|
||||
import com.alibaba.nacos.api.config.ConfigService;
|
||||
import com.alibaba.nacos.api.config.listener.AbstractListener;
|
||||
import com.gitee.fastmybatis.core.query.Query;
|
||||
import com.gitee.sop.gateway.mapper.ConfigRouteBaseMapper;
|
||||
import com.gitee.sop.gateway.mapper.ConfigRouteLimitMapper;
|
||||
import com.gitee.sop.gatewaycommon.bean.ChannelMsg;
|
||||
import com.gitee.sop.gatewaycommon.bean.RouteDefinition;
|
||||
import com.gitee.sop.gatewaycommon.bean.NacosConfigs;
|
||||
import com.gitee.sop.gatewaycommon.bean.RouteConfig;
|
||||
import com.gitee.sop.gatewaycommon.bean.RouteDefinition;
|
||||
import com.gitee.sop.gatewaycommon.bean.TargetRoute;
|
||||
import com.gitee.sop.gatewaycommon.manager.DefaultRouteConfigManager;
|
||||
import com.gitee.sop.gatewaycommon.manager.RouteRepositoryContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.alibaba.nacos.NacosConfigProperties;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -38,8 +38,8 @@ public class DbRouteConfigManager extends DefaultRouteConfigManager {
|
||||
@Autowired
|
||||
Environment environment;
|
||||
|
||||
@Autowired
|
||||
private NacosConfigProperties nacosConfigProperties;
|
||||
@NacosInjected
|
||||
private ConfigService configService;
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
@@ -75,7 +75,6 @@ public class DbRouteConfigManager extends DefaultRouteConfigManager {
|
||||
|
||||
@PostConstruct
|
||||
protected void after() throws Exception {
|
||||
ConfigService configService = nacosConfigProperties.configServiceInstance();
|
||||
configService.addListener(NacosConfigs.DATA_ID_ROUTE_CONFIG, NacosConfigs.GROUP_CHANNEL, new AbstractListener() {
|
||||
@Override
|
||||
public void receiveConfigInfo(String configInfo) {
|
||||
|
@@ -36,8 +36,9 @@ ribbon.OkToRetryOnAllOperations=false
|
||||
|
||||
# nacos cloud配置
|
||||
spring.cloud.nacos.discovery.server-addr=${nacos.url}
|
||||
nacos.config.server-addr=${nacos.url}
|
||||
|
||||
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/sop?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
|
||||
spring.datasource.username=${mysql.username}
|
||||
spring.datasource.password=${mysql.password}
|
||||
|
@@ -1,3 +0,0 @@
|
||||
spring.application.name=api-gateway
|
||||
# nacos的config需要放在bootstrap.properties中
|
||||
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
|
Reference in New Issue
Block a user