引入Nacos服务注册与发现
This commit is contained in:
@@ -31,6 +31,17 @@
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||
</dependency>
|
||||
<!-- Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<groupId>org.yaml</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- logback -->
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
|
@@ -2,8 +2,10 @@ package com.cxyxiaomo.epp;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
public class Gateway {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Gateway.class, args);
|
||||
|
@@ -6,6 +6,9 @@ spring:
|
||||
application:
|
||||
name: microservice-gateway
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 127.0.0.1:8848
|
||||
gateway:
|
||||
discovery:
|
||||
locator:
|
||||
|
@@ -27,6 +27,30 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<!-- Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- jackson -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
<!-- logback -->
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
|
@@ -2,10 +2,12 @@ package com.cxyxiaomo.epp;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
|
||||
// 启动类
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
public class TestProvider {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(TestProvider.class, args);
|
||||
|
@@ -5,3 +5,7 @@ server:
|
||||
spring:
|
||||
application:
|
||||
name: microservice-provider-test
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 127.0.0.1:8848
|
||||
|
@@ -32,6 +32,7 @@
|
||||
<mysql.version>8.0.30</mysql.version>
|
||||
<druid.version>1.2.8</druid.version>
|
||||
<!--<mybatis.spring.boot.version>2.2.2</mybatis.spring.boot.version>-->
|
||||
<jackson.version>2.13.4</jackson.version>
|
||||
</properties>
|
||||
|
||||
<!-- 子 module 继承之后,锁定版本 + 不用写groupId和version -->
|
||||
@@ -77,6 +78,20 @@
|
||||
<version>2.6.4</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Nacos -->
|
||||
<!-- 服务注册发现 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
<version>2021.1</version>
|
||||
</dependency>
|
||||
<!-- 配置中心依赖管理 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
<version>2021.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Database -->
|
||||
<!-- mysql -->
|
||||
<dependency>
|
||||
@@ -98,6 +113,23 @@
|
||||
<version>2.2.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- jackson -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Log -->
|
||||
<!-- log4j -->
|
||||
<dependency>
|
||||
|
Reference in New Issue
Block a user