引入Nacos服务注册与发现
This commit is contained in:
parent
ef6467882d
commit
feeb171cff
34
README.md
34
README.md
@ -104,11 +104,11 @@
|
|||||||
|
|
||||||
项目开发环境:Ubuntu Desktop 22.04 LTS、OpenJDK 11、MySQL 8.0.12
|
项目开发环境:Ubuntu Desktop 22.04 LTS、OpenJDK 11、MySQL 8.0.12
|
||||||
|
|
||||||
| 板块 | 技术栈 | 开发工具 | 备注 |
|
| 板块 | 技术栈 | 开发工具 | 备注 |
|
||||||
| ------ | --------------------------------------------------------- | ------------- | ---- |
|
| ------ | ------------------------------------------------------------ | ------------- | ---- |
|
||||||
| 前端 | Vue 3(JavaScript框架)、Element Plus(UI组件库) | VS Code | 暂定 |
|
| 前端 | Vue 3(JavaScript框架)、Element Plus(UI组件库) | VS Code | 暂定 |
|
||||||
| 后端 | Java 11(开发语言)、SpringCloud(微服务)、Redis(缓存) | Intellij IDEA | |
|
| 后端 | Java 11(开发语言)、SpringCloud(微服务)、nacos-server-2.1.2(服务注册与发现)、Redis(缓存) | Intellij IDEA | |
|
||||||
| 数据库 | MySQL(数据存储) | Navicat | |
|
| 数据库 | MySQL(数据存储) | Navicat | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -172,6 +172,24 @@
|
|||||||
|
|
||||||
### 后端
|
### 后端
|
||||||
|
|
||||||
|
#### 启动nacos
|
||||||
|
|
||||||
|
Nacos下载地址:https://github.com/alibaba/nacos/releases/tag/2.1.2
|
||||||
|
|
||||||
|
> standalone代表着单机模式运行,非集群模式
|
||||||
|
>
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd nacos/bin
|
||||||
|
# Windows
|
||||||
|
startup.cmd -m standalone
|
||||||
|
# Linux/Unix/Mac
|
||||||
|
# sh startup.sh -m standalone
|
||||||
|
# bash startup.sh -m standalone
|
||||||
|
```
|
||||||
|
|
||||||
|
Nacos后台默认用户名密码都是:**nacos**
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 前端
|
### 前端
|
||||||
@ -269,6 +287,12 @@ https://start.spring.io/#!type=maven-project&language=java&platformVersion=2.7.5
|
|||||||
|
|
||||||
MVN REPOSITORY:https://mvnrepository.com/
|
MVN REPOSITORY:https://mvnrepository.com/
|
||||||
|
|
||||||
|
#### Nacos
|
||||||
|
|
||||||
|
Quick Start:https://nacos.io/zh-cn/docs/v2/quickstart/quick-start.html
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 前端
|
### 前端
|
||||||
|
|
||||||
#### Element Plus
|
#### Element Plus
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
# 遇到的问题及对应的解决方案
|
# 遇到的问题及对应的解决方案
|
||||||
|
|
||||||
|
### 2022.11
|
||||||
|
|
||||||
|
#### 2022.11.05 nacos启动报错Fail to init node, please see the logs to find the reason.
|
||||||
|
|
||||||
|
Nacos启动程序路径不能有中文名
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 2022.10
|
### 2022.10
|
||||||
|
|
||||||
#### 2022.10.22 CRLF换行替换为LF
|
#### 2022.10.22 CRLF换行替换为LF
|
||||||
|
@ -31,6 +31,17 @@
|
|||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||||
</dependency>
|
</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 -->
|
<!-- logback -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ch.qos.logback</groupId>
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
@ -2,8 +2,10 @@ package com.cxyxiaomo.epp;
|
|||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
@EnableDiscoveryClient
|
||||||
public class Gateway {
|
public class Gateway {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(Gateway.class, args);
|
SpringApplication.run(Gateway.class, args);
|
||||||
|
@ -6,6 +6,9 @@ spring:
|
|||||||
application:
|
application:
|
||||||
name: microservice-gateway
|
name: microservice-gateway
|
||||||
cloud:
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
server-addr: 127.0.0.1:8848
|
||||||
gateway:
|
gateway:
|
||||||
discovery:
|
discovery:
|
||||||
locator:
|
locator:
|
||||||
|
@ -27,6 +27,30 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</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 -->
|
<!-- logback -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ch.qos.logback</groupId>
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
@ -2,10 +2,12 @@ package com.cxyxiaomo.epp;
|
|||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
|
|
||||||
// 启动类
|
// 启动类
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
@EnableDiscoveryClient
|
||||||
public class TestProvider {
|
public class TestProvider {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(TestProvider.class, args);
|
SpringApplication.run(TestProvider.class, args);
|
||||||
|
@ -5,3 +5,7 @@ server:
|
|||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: microservice-provider-test
|
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>
|
<mysql.version>8.0.30</mysql.version>
|
||||||
<druid.version>1.2.8</druid.version>
|
<druid.version>1.2.8</druid.version>
|
||||||
<!--<mybatis.spring.boot.version>2.2.2</mybatis.spring.boot.version>-->
|
<!--<mybatis.spring.boot.version>2.2.2</mybatis.spring.boot.version>-->
|
||||||
|
<jackson.version>2.13.4</jackson.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<!-- 子 module 继承之后,锁定版本 + 不用写groupId和version -->
|
<!-- 子 module 继承之后,锁定版本 + 不用写groupId和version -->
|
||||||
@ -77,6 +78,20 @@
|
|||||||
<version>2.6.4</version>
|
<version>2.6.4</version>
|
||||||
</dependency>
|
</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 -->
|
<!-- Database -->
|
||||||
<!-- mysql -->
|
<!-- mysql -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -98,6 +113,23 @@
|
|||||||
<version>2.2.2</version>
|
<version>2.2.2</version>
|
||||||
</dependency>
|
</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 -->
|
<!-- Log -->
|
||||||
<!-- log4j -->
|
<!-- log4j -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
Loading…
Reference in New Issue
Block a user