diff --git a/mss-eureka/.gitignore b/mss-eureka/.gitignore deleted file mode 100644 index 2af7cefb0a3f1e7df2fc27b8421f0e16b460e680..0000000000000000000000000000000000000000 --- a/mss-eureka/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -target/ -!.mvn/wrapper/maven-wrapper.jar - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -nbproject/private/ -build/ -nbbuild/ -dist/ -nbdist/ -.nb-gradle/ \ No newline at end of file diff --git a/mss-eureka/node-1.bat b/mss-eureka/node-1.bat deleted file mode 100644 index fd2f95d687e00fe302f3b54d86d89c922acd0f76..0000000000000000000000000000000000000000 --- a/mss-eureka/node-1.bat +++ /dev/null @@ -1 +0,0 @@ -java -jar .\target\Micro-Service-Skeleton-Register-0.0.1-SNAPSHOT.jar --spring.profiles.active=node-1 \ No newline at end of file diff --git a/mss-eureka/node-2.bat b/mss-eureka/node-2.bat deleted file mode 100644 index f6dcf0b6d66c55a9fa7e7560f2b3d30db98fe91e..0000000000000000000000000000000000000000 --- a/mss-eureka/node-2.bat +++ /dev/null @@ -1 +0,0 @@ -java -jar .\target\Micro-Service-Skeleton-Register-0.0.1-SNAPSHOT.jar --spring.profiles.active=node-2 \ No newline at end of file diff --git a/mss-eureka/package.bat b/mss-eureka/package.bat deleted file mode 100644 index 0421f58565f4568c0c8c6fe72c4d0197431caabb..0000000000000000000000000000000000000000 --- a/mss-eureka/package.bat +++ /dev/null @@ -1,2 +0,0 @@ -@echo on -mvn clean -e -U package -Dmaven.test.skip=true \ No newline at end of file diff --git a/mss-eureka/pom.xml b/mss-eureka/pom.xml deleted file mode 100644 index 9590a8abe6ed349a81ebc48d8bf4e4c4793a8a13..0000000000000000000000000000000000000000 --- a/mss-eureka/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - 4.0.0 - - - com.microservice.skeleton - Micro-Service-Skeleton-Parent - 2.0.0 - - Micro-Service-Skeleton-Register - 2.0.0 - jar - - mss-eureka - Demo project for Spring Boot - - - - org.springframework.cloud - spring-cloud-starter-netflix-eureka-server - - - org.springframework.boot - spring-boot-starter-actuator - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - build-info - - - - - - - - - diff --git a/mss-eureka/src/main/docker/Dockerfile b/mss-eureka/src/main/docker/Dockerfile deleted file mode 100644 index 6fab50f8730806a8184db0d4ba01b27db1bfac67..0000000000000000000000000000000000000000 --- a/mss-eureka/src/main/docker/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM frolvlad/alpine-oraclejdk8:slim -VOLUME /tmp -ADD Micro-Service-Skeleton-Register.jar Micro-Service-Skeleton-Register.jar -RUN sh -c 'touch /Micro-Service-Skeleton-Register.jar' -ENTRYPOINT ["sh", "-c" , "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /Micro-Service-Skeleton-Register.jar" ] \ No newline at end of file diff --git a/mss-eureka/src/main/java/com/microservice/skeleton/register/RegisterApplication.java b/mss-eureka/src/main/java/com/microservice/skeleton/register/RegisterApplication.java deleted file mode 100644 index 930b04c6248a08fbd207f349b90ccd11fa2dd3f4..0000000000000000000000000000000000000000 --- a/mss-eureka/src/main/java/com/microservice/skeleton/register/RegisterApplication.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.microservice.skeleton.register; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; - -@SpringBootApplication -@EnableEurekaServer -public class RegisterApplication { - - public static void main(String[] args) { - SpringApplication.run(RegisterApplication.class, args); - } -} diff --git a/mss-eureka/src/main/java/com/microservice/skeleton/register/listener/InstanceCancelListener.java b/mss-eureka/src/main/java/com/microservice/skeleton/register/listener/InstanceCancelListener.java deleted file mode 100644 index aaa0bb9897298a72e3e95c34921218f97b4194d1..0000000000000000000000000000000000000000 --- a/mss-eureka/src/main/java/com/microservice/skeleton/register/listener/InstanceCancelListener.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.microservice.skeleton.register.listener; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceCanceledEvent; -import org.springframework.context.ApplicationListener; -import org.springframework.context.annotation.Configuration; -import org.springframework.lang.NonNull; - -/** - * Created by Mr.Yangxiufeng on 2017/12/9. - * Time:13:45 - * ProjectName:Mirco-Service-Skeleton - */ -@Configuration -@Slf4j -public class InstanceCancelListener implements ApplicationListener { - @Override - public void onApplicationEvent(@NonNull EurekaInstanceCanceledEvent event) { - log.info("服务:{}挂了",event.getAppName()); - } -} diff --git a/mss-eureka/src/main/java/com/microservice/skeleton/register/listener/InstanceRegisterListener.java b/mss-eureka/src/main/java/com/microservice/skeleton/register/listener/InstanceRegisterListener.java deleted file mode 100644 index 3a520a402ed7ddb0c48b22a0c08daa4b7e701e5e..0000000000000000000000000000000000000000 --- a/mss-eureka/src/main/java/com/microservice/skeleton/register/listener/InstanceRegisterListener.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.microservice.skeleton.register.listener; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRegisteredEvent; -import org.springframework.context.ApplicationListener; -import org.springframework.context.annotation.Configuration; -import org.springframework.lang.NonNull; - -/** - * Created by Mr.Yangxiufeng on 2017/12/9. - * Time:13:37 - * ProjectName:Mirco-Service-Skeleton - */ -@Configuration -@Slf4j -public class InstanceRegisterListener implements ApplicationListener{ - @Override - public void onApplicationEvent(@NonNull EurekaInstanceRegisteredEvent eurekaInstanceRegisteredEvent) { - log.info("服务:{},注册成功了",eurekaInstanceRegisteredEvent.getInstanceInfo().getAppName()); - } -} diff --git a/mss-eureka/src/main/java/com/microservice/skeleton/register/listener/InstanceRenewListener.java b/mss-eureka/src/main/java/com/microservice/skeleton/register/listener/InstanceRenewListener.java deleted file mode 100644 index eb2a674cb31a349d286c0190dae025782966d9b9..0000000000000000000000000000000000000000 --- a/mss-eureka/src/main/java/com/microservice/skeleton/register/listener/InstanceRenewListener.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.microservice.skeleton.register.listener; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRenewedEvent; -import org.springframework.context.ApplicationListener; -import org.springframework.context.annotation.Configuration; - -/** - * Created by Mr.Yangxiufeng on 2017/12/9. - * Time:13:48 - * ProjectName:Mirco-Service-Skeleton - */ -@Configuration -@Slf4j -public class InstanceRenewListener implements ApplicationListener { - @Override - public void onApplicationEvent(EurekaInstanceRenewedEvent event) { - log.info("心跳检测服务:{}" ,event.getInstanceInfo().getAppName()); - } -} diff --git a/mss-eureka/src/main/resources/application-node-1.yml b/mss-eureka/src/main/resources/application-node-1.yml deleted file mode 100644 index 2ebcb2a987a084261750bca8aea602296de25ad7..0000000000000000000000000000000000000000 --- a/mss-eureka/src/main/resources/application-node-1.yml +++ /dev/null @@ -1,15 +0,0 @@ -server: - port: 9010 -spring: - application: - ##name必须一样,不然高可用会导致unavailable-replicas - name: mss-eureka -eureka: - instance: - hostname: mss-eureka1 - client: - ##这里要覆盖application的设置,不然会读取application文件导致unavailable-replicas - register-with-eureka: true - fetch-registry: true - service-url: - defaultZone: http://mss-eureka2:9011/eureka/ \ No newline at end of file diff --git a/mss-eureka/src/main/resources/application-node-2.yml b/mss-eureka/src/main/resources/application-node-2.yml deleted file mode 100644 index 5d6ab915286e4b2dec2458c63ee65c9d81075b6e..0000000000000000000000000000000000000000 --- a/mss-eureka/src/main/resources/application-node-2.yml +++ /dev/null @@ -1,14 +0,0 @@ -server: - port: 9011 -spring: - application: - name: mss-eureka -eureka: - instance: - hostname: mss-eureka2 - client: - ##这里要覆盖application的设置,不然会读取application文件导致unavailable-replicas - register-with-eureka: true - fetch-registry: true - service-url: - defaultZone: http://mss-eureka1:9010/eureka/ \ No newline at end of file diff --git a/mss-eureka/src/main/resources/application.yml b/mss-eureka/src/main/resources/application.yml deleted file mode 100644 index 8047e267af8fe007bef37cdeb6c1b33b3d4b9c93..0000000000000000000000000000000000000000 --- a/mss-eureka/src/main/resources/application.yml +++ /dev/null @@ -1,22 +0,0 @@ -server: - port: 9010 -spring: - application: - name: mss-eureka - jackson: - date-format: yyyy-MM-dd HH:mm:ss - joda-date-time-format: yyyy-MM-dd HH:mm:ss - locale: zh_CN - time-zone: GMT+8 -eureka: - instance: - hostname: mss-eureka - client: - register-with-eureka: false - fetch-registry: false - service-url: - defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/ - server: - #### 清理间隔(单位毫秒,默认是60*1000),开发环境设置如下可快速移除不可用的服务 - eviction-interval-timer-in-ms: 5000 - enable-self-preservation: false \ No newline at end of file diff --git a/mss-eureka/src/main/resources/logback.xml b/mss-eureka/src/main/resources/logback.xml deleted file mode 100644 index 741125924750b7fbbc6f4d8125ef786a2962e23d..0000000000000000000000000000000000000000 --- a/mss-eureka/src/main/resources/logback.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - %d{MM/dd/yyyy HH:mm:ss} %-5level [%thread%X{sourceThread}]%logger{24} - %msg%n - - - - - /export/logs/Micro-Service-Skeleton/register-center/log.log - - /export/logs/Micro-Service-Skeleton/register-center/log.%d{yyyy-MM-dd}.log.gz - 7 - - - %d{MM/dd/yyyy HH:mm:ss} %-5level ${version} [%thread]%logger{16} - %msg%n - - - - - - - ERROR - - /export/logs/Micro-Service-Skeleton/register-center/error.log - - /export/logs/Micro-Service-Skeleton/register-center/error-%d{yyyyMMdd}.log.%i - - - 500MB - - 2 - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} -%msg%n - - - - - - /export/logs/Micro-Service-Skeleton/register-center/sql.log - - /export/logs/Micro-Service-Skeleton/register-center/sql.%d{yyyy-MM-dd}.log.gz - 7 - - - %d{MM/dd/yyyy HH:mm:ss} %-5level ${version} [%thread]%logger{16} - %msg%n - - - - - - - - - - - - - - - - diff --git a/mss-eureka/src/test/java/com/microservice/skeleton/register/RegisterApplicationTests.java b/mss-eureka/src/test/java/com/microservice/skeleton/register/RegisterApplicationTests.java deleted file mode 100644 index 363883b6b42f377ee04ef8998aab91cf058ed252..0000000000000000000000000000000000000000 --- a/mss-eureka/src/test/java/com/microservice/skeleton/register/RegisterApplicationTests.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.microservice.skeleton.register; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest -public class RegisterApplicationTests { - - @Test - public void contextLoads() { - } - -} diff --git a/mss-gateway/pom.xml b/mss-gateway/pom.xml index 0d289c623d53481115b48999cef232cb5586f10c..c813f15f313193defbc6d95c7aa0e9d11df7e338 100644 --- a/mss-gateway/pom.xml +++ b/mss-gateway/pom.xml @@ -18,7 +18,11 @@ org.springframework.cloud - spring-cloud-starter-netflix-eureka-client + spring-cloud-starter-alibaba-nacos-discovery + + + org.springframework.cloud + spring-cloud-starter-alibaba-nacos-config org.springframework.cloud diff --git a/mss-gateway/src/main/resources/application.yml b/mss-gateway/src/main/resources/application.yml index c5e0a5b1563f4e62a0e284533d419a2bb3bf4314..30dfe05ea4788cab252e10016eee5933723fecba 100644 --- a/mss-gateway/src/main/resources/application.yml +++ b/mss-gateway/src/main/resources/application.yml @@ -1,17 +1,11 @@ spring: - application: - name: mss-gateway -server: - port: 9030 -eureka: - instance: - prefer-ip-address: true - instance-id: ${spring.cloud.client.ip-address}:${server.port} - lease-renewal-interval-in-seconds: 5 - lease-expiration-duration-in-seconds: 10 - client: - service-url: - defaultZone: http://mss-eureka1:9010/eureka/,http://mss-eureka2:9011/eureka/ + cloud: + nacos: + discovery: + server-addr: 127.0.0.1:8848 + loadbalancer: + retry: + enabled: true zuul: host: connect-timeout-millis: 10000 diff --git a/mss-gateway/src/main/resources/bootstrap.yml b/mss-gateway/src/main/resources/bootstrap.yml new file mode 100644 index 0000000000000000000000000000000000000000..f2052764c42ee7a25ae2ccb00f277055c5715fc8 --- /dev/null +++ b/mss-gateway/src/main/resources/bootstrap.yml @@ -0,0 +1,9 @@ +server: + port: 9030 +spring: + application: + name: mss-gateway + cloud: + nacos: + config: + server-addr: 127.0.0.1:8848 diff --git a/mss-monitor/pom.xml b/mss-monitor/pom.xml index 4e3bd42bf03bf94f3b22216801569abc0c4c3e99..3c73917cdcb50a600f7d57eb4c61eb756894652b 100644 --- a/mss-monitor/pom.xml +++ b/mss-monitor/pom.xml @@ -16,16 +16,15 @@ Demo project for Spring Boot - - org.springframework.cloud - spring-cloud-starter-netflix-eureka-client - - org.springframework.boot spring-boot-starter-test test + + org.springframework.boot + spring-boot-starter-web + org.springframework.boot spring-boot-starter-actuator @@ -36,25 +35,12 @@ org.springframework.cloud - spring-cloud-starter-netflix-hystrix-dashboard + spring-cloud-starter-alibaba-nacos-discovery org.springframework.cloud - spring-cloud-starter-netflix-turbine + spring-cloud-starter-alibaba-nacos-config - - - - - - - - - - - - - diff --git a/mss-monitor/src/main/java/com/microservice/skeleton/monitor/MonitorApplication.java b/mss-monitor/src/main/java/com/microservice/skeleton/monitor/MonitorApplication.java index 5cc75a1ded0170ade1c0b1b6a9668844c6dbf527..20a6f314671e394281095079f391714b7193bf17 100644 --- a/mss-monitor/src/main/java/com/microservice/skeleton/monitor/MonitorApplication.java +++ b/mss-monitor/src/main/java/com/microservice/skeleton/monitor/MonitorApplication.java @@ -3,15 +3,9 @@ package com.microservice.skeleton.monitor; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; -import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; -import org.springframework.cloud.netflix.turbine.EnableTurbine; -import zipkin.server.EnableZipkinServer; @SpringBootApplication @EnableDiscoveryClient -@EnableHystrixDashboard -@EnableTurbine -@EnableZipkinServer public class MonitorApplication { public static void main(String[] args) { diff --git a/mss-monitor/src/main/resources/application.yml b/mss-monitor/src/main/resources/application.yml index 21b0eb31e2c345264b34ce169e47fa9d5a998176..bcdc6e80357060e63eb19d2f6faabd8f751ff2f3 100644 --- a/mss-monitor/src/main/resources/application.yml +++ b/mss-monitor/src/main/resources/application.yml @@ -1,24 +1,7 @@ server: port: 9050 spring: - application: - name: micro-service-monitor -eureka: - instance: - prefer-ip-address: true - instance-id: ${spring.cloud.client.ipAddress}:${server.port} - lease-renewal-interval-in-seconds: 5 - lease-expiration-duration-in-seconds: 10 - client: - service-url: - defaultZone: http://mss-eureka1:9010/eureka/,http://mss-eureka2:9011/eureka/ -endpoints: - health: - sensitive: false - enabled: true -management: - security: - enabled: false -turbine: - app-config-list: micro-a-service - cluster-name-expression: "'default'" \ No newline at end of file + cloud: + nacos: + discovery: + server-addr: 127.0.0.1:8848 \ No newline at end of file diff --git a/mss-monitor/src/main/resources/bootstrap.yml b/mss-monitor/src/main/resources/bootstrap.yml new file mode 100644 index 0000000000000000000000000000000000000000..9de9057b293edc38c8b0df1a78b592c0fe3735c5 --- /dev/null +++ b/mss-monitor/src/main/resources/bootstrap.yml @@ -0,0 +1,7 @@ +spring: + application: + name: micro-service-monitor + cloud: + nacos: + config: + server-addr: 127.0.0.1:8848 diff --git a/mss-oauth/pom.xml b/mss-oauth/pom.xml index 02796d6db0d4c0d6c60aee31d0c03189165ec9b9..ad21e1306ee038488af4b10839cd62b2ce1c8f76 100644 --- a/mss-oauth/pom.xml +++ b/mss-oauth/pom.xml @@ -27,7 +27,11 @@ org.springframework.cloud - spring-cloud-starter-netflix-eureka-client + spring-cloud-starter-alibaba-nacos-discovery + + + org.springframework.cloud + spring-cloud-starter-alibaba-nacos-config org.springframework.cloud diff --git a/mss-oauth/src/main/resources/application.yml b/mss-oauth/src/main/resources/application.yml index f61f66850af5b8bd2b11f0a2fdd44e4a50d55302..03d77189049fceeaad7e9ca010274b9b1c8eeb93 100644 --- a/mss-oauth/src/main/resources/application.yml +++ b/mss-oauth/src/main/resources/application.yml @@ -1,9 +1,6 @@ server: port: 9060 - spring: - application: - name: uaa jpa: show-sql: true datasource: @@ -16,17 +13,11 @@ spring: host: 127.0.0.1 port: 6379 password: 123456 -eureka: - instance: - prefer-ip-address: true - instance-id: ${spring.cloud.client.ip-address}:${server.port} - ##续约更新时间间隔设置5秒,m默认30s - lease-renewal-interval-in-seconds: 5 - ##续约到期时间10秒,默认是90秒 - lease-expiration-duration-in-seconds: 10 - client: - service-url: - defaultZone: http://mss-eureka1:9010/eureka/ + cloud: + nacos: + discovery: + server-addr: 127.0.0.1:8848 + logging: config: classpath:logback.xml level: diff --git a/mss-oauth/src/main/resources/bootstrap.yml b/mss-oauth/src/main/resources/bootstrap.yml new file mode 100644 index 0000000000000000000000000000000000000000..a6c3d52f62f9e15ceb5f9ad5f3dee80e450225a6 --- /dev/null +++ b/mss-oauth/src/main/resources/bootstrap.yml @@ -0,0 +1,7 @@ +spring: + application: + name: uaa + cloud: + nacos: + config: + server-addr: 127.0.0.1:8848 diff --git a/mss-upms/pom.xml b/mss-upms/pom.xml index aaaaa2d72baac8ccd2c16356b82d277a1ccdfe70..dcac7fd0d995196c6c3c07b6c85b7f28ec245132 100644 --- a/mss-upms/pom.xml +++ b/mss-upms/pom.xml @@ -26,7 +26,11 @@ org.springframework.cloud - spring-cloud-starter-netflix-eureka-client + spring-cloud-starter-alibaba-nacos-discovery + + + org.springframework.cloud + spring-cloud-starter-alibaba-nacos-config com.microservice.skeleton.common diff --git a/mss-upms/src/main/resources/application.yml b/mss-upms/src/main/resources/application.yml index f747bafd2578086810b898035582a2dda13b95f2..574356e519115dfb86bd73bdf161bffa00872503 100644 --- a/mss-upms/src/main/resources/application.yml +++ b/mss-upms/src/main/resources/application.yml @@ -1,24 +1,16 @@ server: port: 9021 spring: - application: - name: mss-upms datasource: url: jdbc:mysql://localhost:3306/zuul-auth?useUnicode=true&characterEncoding=utf-8 username: root password: 123456 druid: driver-class-name: com.mysql.jdbc.Driver -eureka: - instance: - prefer-ip-address: true #使用IP注册 - instance-id: ${spring.cloud.client.ip-address}:${server.port} - ##续约更新时间间隔设置5秒,m默认30s - lease-renewal-interval-in-seconds: 5 - ##续约到期时间10秒,默认是90秒 - lease-expiration-duration-in-seconds: 10 - client: - service-url: - defaultZone: http://mss-eureka1:9010/eureka/,http://mss-eureka2:9011/eureka/ + cloud: + nacos: + discovery: + server-addr: 127.0.0.1:8848 + mybatis: mapper-locations: classpath:mapper/*.xml \ No newline at end of file diff --git a/mss-upms/src/main/resources/bootstrap.yml b/mss-upms/src/main/resources/bootstrap.yml new file mode 100644 index 0000000000000000000000000000000000000000..568474e6e2ec1a0a4b35ea874492f509b31bd54e --- /dev/null +++ b/mss-upms/src/main/resources/bootstrap.yml @@ -0,0 +1,7 @@ +spring: + application: + name: mss-upms + cloud: + nacos: + config: + server-addr: 127.0.0.1:8848 diff --git a/pom.xml b/pom.xml index 2b6b694fb8842292ae4e2bcfea5030cebd0cf539..5d1b77da37483736fcf04163b253b1cdb1ef4fba 100644 --- a/pom.xml +++ b/pom.xml @@ -34,7 +34,6 @@ mss-common - mss-eureka mss-oauth mss-gateway mss-monitor @@ -83,6 +82,13 @@ springfox-swagger-ui ${swagger2.version} + + org.springframework.cloud + spring-cloud-starter-alibaba-nacos-config + 0.2.1.RELEASE + pom + import +