This commit is contained in:
tanghc
2020-07-28 18:21:01 +08:00
parent ee30f18d53
commit 0fea955db9
165 changed files with 918 additions and 4838 deletions

View File

@@ -17,17 +17,17 @@
</properties>
<dependencies>
<!--
<artifactId>sop-bridge-nacos</artifactId> : 使用nacos注册中心
<artifactId>sop-bridge-eureka</artifactId> : 使用eureka注册中心
-->
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-gateway-common</artifactId>
<artifactId>sop-bridge-nacos</artifactId>
<!--<artifactId>sop-bridge-eureka</artifactId>-->
<version>3.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>

View File

@@ -4,8 +4,6 @@ import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import com.gitee.sop.gatewaycommon.manager.EnvironmentContext;
import com.gitee.sop.gatewaycommon.route.EurekaRegistryListener;
import com.gitee.sop.gatewaycommon.route.NacosRegistryListener;
import com.gitee.sop.gatewaycommon.route.RegistryListener;
import com.gitee.sop.gatewaycommon.route.ServiceListener;
import com.gitee.sop.websiteserver.listener.ServiceDocListener;
@@ -14,7 +12,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.client.discovery.event.HeartbeatEvent;
import org.springframework.context.ApplicationEvent;
@@ -65,21 +62,6 @@ public class WebsiteConfig implements ApplicationRunner {
registryListener.onEvent(heartbeatEvent);
}
/**
* 微服务路由加载
*/
@Bean
@ConditionalOnProperty("spring.cloud.nacos.discovery.server-addr")
RegistryListener registryListenerNacos() {
return new NacosRegistryListener();
}
@Bean
@ConditionalOnProperty("eureka.client.serviceUrl.defaultZone")
RegistryListener registryListenerEureka() {
return new EurekaRegistryListener();
}
@Bean
@ConditionalOnMissingBean
ServiceListener serviceListener() {

View File

@@ -0,0 +1,2 @@
# 自定义自动配置类,如果有多个类,使用逗号(,)分隔,\正斜杠标示换行还可以读取到指定的类
org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.gitee.sop.bridge.SopRegisterAutoConfiguration

View File

@@ -2,8 +2,8 @@ server.port=8083
spring.application.name=sop-website
# ------- 需要改的配置 -------
# nacos地址
nacos.url=127.0.0.1:8848
# 注册中心地址
register.url=127.0.0.1:8848
# 网关内网地址
# !!沙箱环境是提供给外部的测试环境,不能把正式环境当做沙箱环境来使用。
@@ -11,7 +11,9 @@ gateway.url=http://localhost:8081
# ------- 需要改的配置end -------
## nacos cloud配置
spring.cloud.nacos.discovery.server-addr=${nacos.url}
spring.cloud.nacos.discovery.server-addr=${register.url}
# eureka地址
eureka.client.serviceUrl.defaultZone=${register.url}
# 页面上显示的测试环境地址
api.url-test=http://open-test.yourdomain.com