Skip to content

Commit

Permalink
update nacos 2.4.2,seata 2.1.0,spring boot 3.2.9 (#3843)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimyjie authored Sep 18, 2024
1 parent 197c0d1 commit e9ca0e8
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 34 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<spring.cloud.version>2023.0.3</spring.cloud.version>

<!-- Spring Boot -->
<spring-boot.version>3.2.7</spring-boot.version>
<spring-boot.version>3.2.9</spring-boot.version>

<!-- Maven Plugin Versions -->
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
Expand Down
11 changes: 5 additions & 6 deletions spring-cloud-alibaba-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<properties>
<revision>2023.0.1.2</revision>
<sentinel.version>1.8.8</sentinel.version>
<nacos.client.version>2.3.2</nacos.client.version>
<seata.version>2.0.0</seata.version>
<nacos.client.version>2.4.2</nacos.client.version>
<seata.version>2.1.0</seata.version>
<!-- Apache RocketMQ -->
<rocketmq.version>5.1.4</rocketmq.version>

Expand All @@ -35,7 +35,7 @@

<!-- Maven Plugin Versions -->
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
<maven-javadoc-plugin.version>3.1.1</maven-javadoc-plugin.version>
<maven-javadoc-plugin.version>3.2.0</maven-javadoc-plugin.version>
<maven-gpg-plugin.version>3.0.1</maven-gpg-plugin.version>
<flatten-maven-plugin.version>1.2.7</flatten-maven-plugin.version>
</properties>
Expand Down Expand Up @@ -169,10 +169,9 @@
<artifactId>sentinel-spring-webmvc-v6x-adapter</artifactId>
<version>${sentinel.version}</version>
</dependency>

<!--Alibaba Seata-->
<!--apache Seata-->
<dependency>
<groupId>io.seata</groupId>
<groupId>org.apache.seata</groupId>
<artifactId>seata-spring-boot-starter</artifactId>
<version>${seata.version}</version>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:

# nacos
nacos:
image: nacos/nacos-server:v2.1.0
image: nacos/nacos-server:v2.4.2
hostname: nacos-server
restart: always
container_name: integrated-example-nacos
Expand Down
16 changes: 8 additions & 8 deletions spring-cloud-alibaba-examples/nacos-example/readme-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@

[Nacos](https://github.com/alibaba/Nacos) 是阿里巴巴开源的一个更易于构建云原生应用的动态服务发现、配置管理和服务管理平台。

## 正确配置并启动 Nacos Server 2.3.2
## 正确配置并启动 Nacos Server 2.4.2

在 Nacos 2.3.2 中,加入了用户鉴权相关的功能,在首次启动 Nacos Server 时,需要正确配置,避免出现启动失败的问题。
在 Nacos 2.4.2 中,加入了用户鉴权相关的功能,在首次启动 Nacos Server 时,需要正确配置,避免出现启动失败的问题。

### 下载 Nacos Server

> 本示例中使用 Nacos Server 版本为 2.3.2!
> 本示例中使用 Nacos Server 版本为 2.4.2!
Nacos 支持直接下载和源码构建两种方式。**推荐在 Spring Cloud Alibaba 2023.x 中使用 Nacos Server 2.3.2 版本。**
Nacos 支持直接下载和源码构建两种方式。**推荐在 Spring Cloud Alibaba 2023.x 中使用 Nacos Server 2.4.2 版本。**

1. 直接下载:[Nacos Server 下载页](https://github.com/alibaba/nacos/releases)
2. 源码构建:进入 Nacos [Github 项目页面](https://github.com/alibaba/nacos),将代码 git clone 到本地自行编译打包,[参考文档](https://nacos.io/zh-cn/docs/quick-start.html)

### 配置 Nacos Server

打开 `\nacos-server-2.3.2\conf\application.properties` 配置文件,修改以下配置项:
打开 `\nacos-server-2.4.2\conf\application.properties` 配置文件,修改以下配置项:

#### 配置数据源

此处以 MySQL 数据库为例,使用 `nacos-server-2.3.2\conf\mysql-schema.sql` 初始化数据库表文件。同时修改以下配置
此处以 MySQL 数据库为例,使用 `nacos-server-2.4.2\conf\mysql-schema.sql` 初始化数据库表文件。同时修改以下配置

```properties
#*************** Config Module Related Configurations ***************#
Expand All @@ -49,7 +49,7 @@ db.pool.config.minimumIdle=2

#### 开启鉴权

**注意:不开启在 2.3.2 中会出现登陆失败异常!**
**注意:不开启在 2.4.2 中会出现登陆失败异常!**

```properties
### The auth system to use, currently only 'nacos' and 'ldap' is supported:
Expand Down Expand Up @@ -77,7 +77,7 @@ nacos.core.auth.plugin.nacos.token.secret.key=SecretKey0123456789012345678901234

#### Open API 鉴权

在 nacos server 2.3.2 中使用 Open api 接口时需要鉴权:更多细节请参考:[Nacos api 鉴权](https://nacos.io/zh-cn/docs/auth.html)
在 nacos server 2.4.2 中使用 Open api 接口时需要鉴权:更多细节请参考:[Nacos api 鉴权](https://nacos.io/zh-cn/docs/auth.html)

1. 获取 accessToken:使用用户名和密码登陆 nacos server:

Expand Down
8 changes: 4 additions & 4 deletions spring-cloud-alibaba-examples/nacos-example/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ This project demonstrates how to use Spring Cloud Alibaba Nacos related Starters

[Nacos](https://github.com/alibaba/Nacos) It is Alibaba's open source dynamic service discovery, configuration management and service management platform that is easier to build cloud-native applications.

## Nacos Server 2.3.2 is properly configured and started
## Nacos Server 2.4.2 is properly configured and started

In Nacos 2.3.2, functions related to user authentication are added. When starting Nacos Server for the first time, it needs to be configured correctly to avoid the problem of startup failure.
In Nacos 2.4.2, functions related to user authentication are added. When starting Nacos Server for the first time, it needs to be configured correctly to avoid the problem of startup failure.

### Download Nacos Server

Expand Down Expand Up @@ -49,7 +49,7 @@ db.pool.config.minimumIdle=2

#### Turn on authentication

**Note: If it is not enabled, login failure exception will occur in 2.3.2!**
**Note: If it is not enabled, login failure exception will occur in 2.4.2!**

```properties
### The auth system to use, currently only 'nacos' and 'ldap' is supported:
Expand Down Expand Up @@ -77,7 +77,7 @@ nacos.core.auth.plugin.nacos.token.secret.key=SecretKey0123456789012345678901234

#### Open API authentication

Authentication is required when using the Open api interface in nacos server 2.3.2: For more details, please refer to: [Nacos api authentication](https://nacos.io/zh-cn/docs/auth.html)
Authentication is required when using the Open api interface in nacos server 2.4.2: For more details, please refer to: [Nacos api authentication](https://nacos.io/zh-cn/docs/auth.html)

1. Obtain accessToken: Use username and password to log in to the nacos server:

Expand Down
10 changes: 5 additions & 5 deletions spring-cloud-alibaba-examples/seata-example/readme-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ CREATE TABLE `undo_log` (
```

#### 导入 seata-server db 模式所需要的数据库表
在数据库中初始化[global_table、branch_table、lock_table、distributed_lock](https://github.com/seata/seata/blob/2.0.0/script/server/db/mysql.sql)
在数据库中初始化[global_table、branch_table、lock_table、distributed_lock](https://github.com/seata/seata/blob/2.1.0/script/server/db/mysql.sql)

```sql
-- -------------------------------- The script used when storeMode is 'db' --------------------------------
Expand Down Expand Up @@ -164,7 +164,7 @@ CREATE TABLE `account_tbl` (

> Spring Cloud Alibaba 适配了 Nacos 2.2.3 版本,在本示例中,使用 Nacos 2.2.3 作为 Seata 的配置中心组件。
创建 Seata 的 Nacos 配置: data-id: `seata.properties` , Group: `SEATA_GROUP` (seata 2.0.0 默认分组) ,导入 [Seata Config](https://github.com/seata/seata/blob/2.0.0/script/config-center/config.txt)
创建 Seata 的 Nacos 配置: data-id: `seata.properties` , Group: `SEATA_GROUP` (seata 2.1.0 默认分组) ,导入 [Seata Config](https://github.com/seata/seata/blob/2.1.0/script/config-center/config.txt)

`seata.properties` 配置文件中增加应用示例中需要的以下配置项:[事务群组配置](https://seata.io/zh-cn/docs/user/configurations.html)

Expand All @@ -181,11 +181,11 @@ CREATE TABLE `account_tbl` (
#### 1. 下载

点击下载 [Seata 2.0.0](https://github.com/seata/seata/releases/download/v2.0.0/seata-server-2.0.0.zip) 版本。
点击下载 [Seata 2.1.0](https://github.com/seata/seata/releases/download/v2.1.0/seata-server-2.1.0.zip) 版本。

#### 2. 配置 Seata-server

修改 `seata-server-2.0.0\conf\application.yml` 配置文件中的以下配置项:
修改 `seata-server-2.1.0\conf\application.yml` 配置文件中的以下配置项:

- 注释 `group: SEATA_GROUP`
- 添加 Nacos 用户名和密码
Expand Down Expand Up @@ -220,7 +220,7 @@ seata:
```
> **注意:**
> Nacos 2.3.2 开启鉴权,需要配置 `username` 和 `password` 属性,否则登陆失败。更多 Nacos 2.3.2 版本相关配置,参考 `nacos-example`。
> Nacos 2.4.2 开启鉴权,需要配置 `username` 和 `password` 属性,否则登陆失败。更多 Nacos 2.4.2 版本相关配置,参考 `nacos-example`。
> **Seata-server 启动时的 Nacos 服务注册分组需要和示例应用中的分组保持一致,否则出现无法找到 seata-server 的错误!**
> 更多 Seata-server 以 Nacos 作为配置中心的配置请参考:https://seata.io/zh-cn/docs/ops/deploy-by-docker-compose/#nacos-db

Expand Down
12 changes: 6 additions & 6 deletions spring-cloud-alibaba-examples/seata-example/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ CREATE TABLE `undo_log` (
```

#### Import the database tables required by the seata-server db schema
Initializing [global_table、branch_table、lock_table、distributed_lock](https://github.com/seata/seata/blob/2.0.0/script/server/db/mysql.sql) in the database
Initializing [global_table、branch_table、lock_table、distributed_lock](https://github.com/seata/seata/blob/2.1.0/script/server/db/mysql.sql) in the database

```sql
-- -------------------------------- The script used when storeMode is 'db' --------------------------------
Expand Down Expand Up @@ -162,9 +162,9 @@ CREATE TABLE `account_tbl` (

### 2. Configure Nacos

> Spring Cloud Alibaba is adapted with Nacos 2.3.2. In this example, Nacos 2.3.2 is used as the configuration center component of Seata.
> Spring Cloud Alibaba is adapted with Nacos 2.4.2. In this example, Nacos 2.4.2 is used as the configuration center component of Seata.
Create Nacos configuration for Seata: data-id: `seata.properties`, Group: `SEATA_GROUP` (default grouping for seata 2.0.0), import
Create Nacos configuration for Seata: data-id: `seata.properties`, Group: `SEATA_GROUP` (default grouping for seata 2.1.0), import

Add the following configuration items required in the application example to the `seata.properties` configuration file: [事务群组配置](https://seata.io/zh-cn/docs/user/configurations.html)

Expand All @@ -181,11 +181,11 @@ Add the following configuration items required in the application example to the
#### 1. Download

Click Download [Seata 2.0.0](https://github.com/seata/seata/releases/download/v2.0.0/seata-server-2.0.0.zip) Version.
Click Download [Seata 2.1.0](https://github.com/seata/seata/releases/download/v2.1.0/seata-server-2.1.0.zip) Version.

#### 2. Configure Seata-server

Modify `seata-server-2.0.0\conf\application.yml` the following configuration items in the configuration file:
Modify `seata-server-2.1.0\conf\application.yml` the following configuration items in the configuration file:

- Comment `group: SEATA_GROUP`
- Add Nacos username and password
Expand Down Expand Up @@ -220,7 +220,7 @@ seata:
```
> **Notice**
> Nacos 2.3.2 enables authentication. Configuration `username` and `password` properties are required, otherwise login fails. For more Nacos 2.3.2 related configurations, refer to `nacos-example`.
> Nacos 2.4.2 enables authentication. Configuration `username` and `password` properties are required, otherwise login fails. For more Nacos 2.4.2 related configurations, refer to `nacos-example`.
> **The Nacos service registration group when seata-server is started must be consistent with the group in the sample application, otherwise an error that seata-server cannot be found will occur!**
> For more information about the configuration of Seata-server with Nacos as the configuration center, please refer to https://seata.io/zh-cn/docs/ops/deploy-by-docker-compose/#nacos-db.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.api.naming.pojo.ListView;
import com.alibaba.nacos.api.naming.pojo.ServiceInfo;
import com.alibaba.nacos.api.naming.selector.NamingSelector;
import com.alibaba.nacos.api.selector.AbstractSelector;

/**
Expand Down Expand Up @@ -349,4 +350,24 @@ private ListView<String> emptyListView() {
emptyListView.setData(Collections.emptyList());
return emptyListView;
}

@Override
public void subscribe(String s, NamingSelector namingSelector, EventListener eventListener) throws NacosException {

}

@Override
public void subscribe(String s, String s1, NamingSelector namingSelector, EventListener eventListener) throws NacosException {

}

@Override
public void unsubscribe(String s, NamingSelector namingSelector, EventListener eventListener) throws NacosException {

}

@Override
public void unsubscribe(String s, String s1, NamingSelector namingSelector, EventListener eventListener) throws NacosException {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</dependency>

<dependency>
<groupId>io.seata</groupId>
<groupId>org.apache.seata</groupId>
<artifactId>seata-spring-boot-starter</artifactId>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
nacos:
image: nacos/nacos-server:2.0.1
image: nacos/nacos-server:v2.4.2
container_name: nacos-standalone
environment:
- PREFER_HOST_MODE=hostname
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
nacos:
image: nacos/nacos-server:2.0.1
image: nacos/nacos-server:v2.4.2
container_name: nacos-standalone
environment:
- PREFER_HOST_MODE=hostname
Expand Down

0 comments on commit e9ca0e8

Please sign in to comment.