diff --git a/README.md b/README.md
index f9041d1..8969457 100644
--- a/README.md
+++ b/README.md
@@ -66,6 +66,7 @@ A Managerment API Gateway in Java . Fizz Gateway 是一个基于 Java开发的
| v1.0.0 | v1.0.0 | v1.0.0 |
| v1.1.0 | v1.1.0 | v1.1.0 |
| v1.1.1 | v1.1.1 | v1.1.1 |
+| v1.2.0 | v1.2.0 | v1.1.1 |
请根据社区版的版本下载对应的管理后台版本
@@ -93,13 +94,13 @@ A Managerment API Gateway in Java . Fizz Gateway 是一个基于 Java开发的
##### 管理后台服务端(fizz-manager-professional)
-1. 首次安装执行`fizz-manager-professional-1.1.1-mysql.sql`数据库脚本
-2. 将`application-prod.yml`、`boot.sh`、`fizz-manager-professional-1.1.1.jar`拷贝到`/data/webapps/fizz-manager-professional`目录下
+1. 首次安装执行`fizz-manager-professional-1.2.0-mysql.sql`数据库脚本
+2. 将`application-prod.yml`、`boot.sh`、`fizz-manager-professional-1.2.0.jar`拷贝到`/data/webapps/fizz-manager-professional`目录下
3. 修改`application-prod.yml`文件,将相关配置修改成部署环境的配置
4. 修改`boot.sh`文件,将`RUN_CMD`变量值修改成部署环境的JAVA实际路径
5. 执行 `chmod +x boot.sh` 命令给`boot.sh`增加执行权限
6. 执行 `./boot.sh start` 命令启动服务,支持 start/stop/restart/status命令
-7. 服务启动后访问 http://IP:8000/fizz-manager (将IP替换成服务部署机器IP地址),使用超级管理员账户`admin`密码`Aa123!`登录
+7. 服务启动后访问前端登录地址,使用超级管理员账户`admin`密码`Aa123!`登录
##### 管理后台前端(fizz-admin-professional)
@@ -126,11 +127,14 @@ server {
#### 二、安装fizz-gateway-community社区版
-说明:如果使用apollo配置中心,可把application.yml文件内容迁到配置中心(apollo上应用名为:fizz-gateway);使用不使用apollo可去掉下面启动命令里的apollo参数。
+说明:
+
+1. 支持配置中心:apollo、nacos,支持注册中心:eureka、nacos,详细配置方法查看application.yml文件。
+2. 如果使用apollo配置中心,可把application.yml文件内容迁到配置中心(apollo上应用名为:fizz-gateway);如果不使用apollo可去掉下面启动命令里的apollo参数。
安装方式一:脚本启动:
-1. 下载fizz-gateway-community的最新代码,修改application.yml配置文件里eureka、redis的配置,使用maven命令`mvn clean package -DskipTests=true`构建并把构建好的fizz-gateway-community-1.1.1.jar和boot.sh放同一目录
+1. 下载fizz-gateway-community的最新代码,修改application.yml配置文件里配置中心、注册中心、redis的配置,使用maven命令`mvn clean package -DskipTests=true`构建并把构建好的fizz-gateway-community-1.2.0.jar和boot.sh放同一目录
2. 修改boot.sh脚本的apollo连接,JVM内存配置
3. 执行 `./boot.sh start` 命令启动服务,支持 start/stop/restart/status命令
@@ -138,13 +142,13 @@ server {
1. 本地clone仓库上的最新代码
2. 将项目fizz-gateway导入IDE
-3. 导入完成后设置项目启动配置及修改application.yml配置文件里eureka、redis的配置,在VM选项中加入`-Denv=dev -Dapollo.meta=http://localhost:66`(Apollo配置中心地址)
+3. 导入完成后设置项目启动配置及修改application.yml配置文件里配置中心、注册中心、redis的配置,在VM选项中加入`-Denv=dev -Dapollo.meta=http://localhost:66`(Apollo配置中心地址)
安装方式三:jar启动:
-1. 本地clone仓库上的最新代码,修改application.yml配置文件里eureka、redis的配置
+1. 本地clone仓库上的最新代码,修改application.yml配置文件里配置中心、注册中心、redis的配置
2. 在项目根目录fizz-gateway-community下执行Maven命令`mvn clean package -DskipTests=true`打包
-3. 进入target目录,使用命令`java -jar -Denv=DEV -Dapollo.meta=http://localhost:66 fizz-gateway-community-1.1.1.jar`启动服务
+3. 进入target目录,使用命令`java -jar -Denv=DEV -Dapollo.meta=http://localhost:66 fizz-gateway-community-1.2.0.jar`启动服务
最后访问网关,地址形式为:http://127.0.0.1:8600/proxy/[服务名]/[API Path]
diff --git a/pom.xml b/pom.xml
index deff66d..691a288 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
we
fizz-gateway-community
- 1.1.1
+ 1.2.0
fizz-gateway-community
diff --git a/sh/boot.sh b/sh/boot.sh
index 9f0a930..5e6eb48 100644
--- a/sh/boot.sh
+++ b/sh/boot.sh
@@ -6,7 +6,7 @@ cd `dirname $0`
#变量定义
APOLLO_META_SERVER=http://localhost:66
ENV=dev
-APP_NAME=fizz-gateway-community-1.1.1.jar
+APP_NAME=fizz-gateway-community-1.2.0.jar
APP_DEP_DIR=/data/webapps/fizz-gateway
APP_LOG_DIR=/data/logs/fizz-gateway
JAVA_CMD=/usr/local/java/bin/java
diff --git a/src/main/java/we/proxy/NacosUriSelector.java b/src/main/java/we/proxy/NacosUriSelector.java
index 28eab8c..fff4144 100644
--- a/src/main/java/we/proxy/NacosUriSelector.java
+++ b/src/main/java/we/proxy/NacosUriSelector.java
@@ -1,5 +1,7 @@
package we.proxy;
+import com.alibaba.boot.nacos.discovery.properties.NacosDiscoveryProperties;
+import com.alibaba.boot.nacos.discovery.properties.Register;
import com.alibaba.nacos.api.annotation.NacosInjected;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.NamingService;
@@ -8,6 +10,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import javax.annotation.PostConstruct;
+import java.util.Collections;
+import java.util.List;
/**
* The Nacos implementation of {@code DiscoveryClientUriSelector}
@@ -19,8 +26,34 @@ import org.springframework.stereotype.Service;
public class NacosUriSelector extends AbstractDiscoveryClientUriSelector {
private static final Logger log = LoggerFactory.getLogger(NacosUriSelector.class);
+ public NacosUriSelector(NacosDiscoveryProperties discoveryProperties) {
+ this.discoveryProperties = discoveryProperties;
+ }
+
@NacosInjected
private NamingService naming;
+ private NacosDiscoveryProperties discoveryProperties;
+ private String groupName;
+ private List clusterNameList;
+ private boolean useGroupName;
+ private boolean userClusterName;
+
+ @PostConstruct
+ public void init() {
+ Register register = discoveryProperties.getRegister();
+ if (register != null) {
+ this.groupName = register.getGroupName();
+ if (StringUtils.hasText(groupName)) {
+ this.useGroupName = true;
+ }
+ String clusterName = register.getClusterName();
+ if (StringUtils.hasText(clusterName)) {
+ this.userClusterName = true;
+ this.clusterNameList = Collections.singletonList(clusterName);
+ }
+
+ }
+ }
@Override
public String getNextUri(String service, String relativeUri) {
@@ -31,7 +64,15 @@ public class NacosUriSelector extends AbstractDiscoveryClientUriSelector {
private Instance selectOneHealthyInstance(String service) {
Instance instance = null;
try {
- instance = naming.selectOneHealthyInstance(service);
+ if (useGroupName && userClusterName) {
+ instance = naming.selectOneHealthyInstance(service, groupName, clusterNameList);
+ } else if (useGroupName) {
+ instance = naming.selectOneHealthyInstance(service, groupName);
+ } else if (userClusterName) {
+ instance = naming.selectOneHealthyInstance(service, clusterNameList);
+ } else {
+ instance = naming.selectOneHealthyInstance(service);
+ }
} catch (NacosException e) {
log.warn("Nacos selectOneHealthyInstance({}) exception", service, e);
}