Source Server Type : MySQL
Source Server Version : 80013
Source Host : localhost:3306
Source Schema : oauth_config
Target Server Type : MySQL
Target Server Version : 80013
File Encoding : 65001
Date: 25/04/2021 11:33:59
SET
NAMES utf8mb4
;
SET
FOREIGN_KEY_CHECKS
=
0
;
DROP
TABLE
IF
EXISTS
`
config_info
`
;
CREATE
TABLE
`
config_info
`
(
`
id
`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
COMMENT
'id'
,
`
data_id
`
varchar
(
255
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NOT
NULL
COMMENT
'data_id'
,
`
group_id
`
varchar
(
255
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
NULL
,
`
content
`
longtext
CHARACTER
SET
utf8
COLLATE
utf8_bin
NOT
NULL
COMMENT
'content'
,
`
md5
`
varchar
(
32
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
NULL
COMMENT
'md5'
,
`
gmt_create
`
datetime
(
0
)
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
(
0
)
COMMENT
'创建时间'
,
`
gmt_modified
`
datetime
(
0
)
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
(
0
)
COMMENT
'修改时间'
,
`
src_user
`
text
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
COMMENT
'source user'
,
`
src_ip
`
varchar
(
50
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
NULL
COMMENT
'source ip'
,
`
app_name
`
varchar
(
128
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
NULL
,
`
tenant_id
`
varchar
(
128
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
''
COMMENT
'租户字段'
,
`
c_desc
`
varchar
(
256
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
NULL
,
`
c_use
`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
NULL
,
`
effect
`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
NULL
,
`
type
`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
NULL
,
`
c_schema
`
text
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
,
PRIMARY
KEY
(
`
id
`
)
USING
BTREE
,
UNIQUE
INDEX
`
uk_configinfo_datagrouptenant
`
(
`
data_id
`
,
`
group_id
`
,
`
tenant_id
`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_bin
COMMENT
=
'config_info'
ROW_FORMAT
=
Dynamic
;
DROP
TABLE
IF
EXISTS
`
config_info_aggr
`
;
CREATE
TABLE
`
config_info_aggr
`
(
`
id
`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
COMMENT
'id'
,
`
data_id
`
varchar
(
255
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NOT
NULL
COMMENT
'data_id'
,
`
group_id
`
varchar
(
255
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NOT
NULL
COMMENT
'group_id'
,
`
datum_id
`
varchar
(
255
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NOT
NULL
COMMENT
'datum_id'
,
`
content
`
longtext
CHARACTER
SET
utf8
COLLATE
utf8_bin
NOT
NULL
COMMENT
'内容'
,
`
gmt_modified
`
datetime
(
0
)
NOT
NULL
COMMENT
'修改时间'
,
`
app_name
`
varchar
(
128
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
NULL
,
`
tenant_id
`
varchar
(
128
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
''
COMMENT
'租户字段'
,
PRIMARY
KEY
(
`
id
`
)
USING
BTREE
,
UNIQUE
INDEX
`
uk_configinfoaggr_datagrouptenantdatum
`
(
`
data_id
`
,
`
group_id
`
,
`
tenant_id
`
,
`
datum_id
`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_bin
COMMENT
=
'增加租户字段'
ROW_FORMAT
=
Dynamic
;
DROP
TABLE
IF
EXISTS
`
config_info_beta
`
;
CREATE
TABLE
`
config_info_beta
`
(
`
id
`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
COMMENT
'id'
,
`
data_id
`
varchar
(
255
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NOT
NULL
COMMENT
'data_id'
,
`
group_id
`
varchar
(
128
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NOT
NULL
COMMENT
'group_id'
,
`
app_name
`
varchar
(
128
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
NULL
COMMENT
'app_name'
,
`
content
`
longtext
CHARACTER
SET
utf8
COLLATE
utf8_bin
NOT
NULL
COMMENT
'content'
,
`
beta_ips
`
varchar
(
1024
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
NULL
COMMENT
'betaIps'
,
`
md5
`
varchar
(
32
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
NULL
COMMENT
'md5'
,
`
gmt_create
`
datetime
(
0
)
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
(
0
)
COMMENT
'创建时间'
,
`
gmt_modified
`
datetime
(
0
)
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
(
0
)
COMMENT
'修改时间'
,
`
src_user
`
text
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
COMMENT
'source user'
,
`
src_ip
`
varchar
(
50
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
NULL
COMMENT
'source ip'
,
`
tenant_id
`
varchar
(
128
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
''
COMMENT
'租户字段'
,
PRIMARY
KEY
(
`
id
`
)
USING
BTREE
,
UNIQUE
INDEX
`
uk_configinfobeta_datagrouptenant
`
(
`
data_id
`
,
`
group_id
`
,
`
tenant_id
`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_bin
COMMENT
=
'config_info_beta'
ROW_FORMAT
=
Dynamic
;
DROP
TABLE
IF
EXISTS
`
config_info_tag
`
;
CREATE
TABLE
`
config_info_tag
`
(
`
id
`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
COMMENT
'id'
,
`
data_id
`
varchar
(
255
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NOT
NULL
COMMENT
'data_id'
,
`
group_id
`
varchar
(
128
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NOT
NULL
COMMENT
'group_id'
,
`
tenant_id
`
varchar
(
128
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
''
COMMENT
'tenant_id'
,
`
tag_id
`
varchar
(
128
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NOT
NULL
COMMENT
'tag_id'
,
`
app_name
`
varchar
(
128
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
NULL
COMMENT
'app_name'
,
`
content
`
longtext
CHARACTER
SET
utf8
COLLATE
utf8_bin
NOT
NULL
COMMENT
'content'
,
`
md5
`
varchar
(
32
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
NULL
COMMENT
'md5'
,
`
gmt_create
`
datetime
(
0
)
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
(
0
)
COMMENT
'创建时间'
,
`
gmt_modified
`
datetime
(
0
)
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
(
0
)
COMMENT
'修改时间'
,
`
src_user
`
text
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
COMMENT
'source user'
,
`
src_ip
`
varchar
(
50
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
NULL
COMMENT
'source ip'
,
PRIMARY
KEY
(
`
id
`
)
USING
BTREE
,
UNIQUE
INDEX
`
uk_configinfotag_datagrouptenanttag
`
(
`
data_id
`
,
`
group_id
`
,
`
tenant_id
`
,
`
tag_id
`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_bin
COMMENT
=
'config_info_tag'
ROW_FORMAT
=
Dynamic
;
DROP
TABLE
IF
EXISTS
`
config_tags_relation
`
;
CREATE
TABLE
`
config_tags_relation
`
(
`
id
`
bigint
(
20
)
NOT
NULL
COMMENT
'id'
,
`
tag_name
`
varchar
(
128
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NOT
NULL
COMMENT
'tag_name'
,
`
tag_type
`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
NULL
COMMENT
'tag_type'
,
`
data_id
`
varchar
(
255
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NOT
NULL
COMMENT
'data_id'
,
`
group_id
`
varchar
(
128
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NOT
NULL
COMMENT
'group_id'
,
`
tenant_id
`
varchar
(
128
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
''
COMMENT
'tenant_id'
,
`
nid
`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
,
PRIMARY
KEY
(
`
nid
`
)
USING
BTREE
,
UNIQUE
INDEX
`
uk_configtagrelation_configidtag
`
(
`
id
`
,
`
tag_name
`
,
`
tag_type
`
)
USING
BTREE
,
INDEX
`
idx_tenant_id
`
(
`
tenant_id
`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_bin
COMMENT
=
'config_tag_relation'
ROW_FORMAT
=
Dynamic
;
DROP
TABLE
IF
EXISTS
`
group_capacity
`
;
CREATE
TABLE
`
group_capacity
`
(
`
id
`
bigint
(
20
)
UNSIGNED
NOT
NULL
AUTO_INCREMENT
COMMENT
'主键ID'
,
`
group_id
`
varchar
(
128
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NOT
NULL
DEFAULT
''
COMMENT
'Group ID,空字符表示整个集群'
,
`
quota
`
int
(
10
)
UNSIGNED
NOT
NULL
DEFAULT
0
COMMENT
'配额,0表示使用默认值'
,
`
usage
`
int
(
10
)
UNSIGNED
NOT
NULL
DEFAULT
0
COMMENT
'使用量'
,
`
max_size
`
int
(
10
)
UNSIGNED
NOT
NULL
DEFAULT
0
COMMENT
'单个配置大小上限,单位为字节,0表示使用默认值'
,
`
max_aggr_count
`
int
(
10
)
UNSIGNED
NOT
NULL
DEFAULT
0
COMMENT
'聚合子配置最大个数,,0表示使用默认值'
,
`
max_aggr_size
`
int
(
10
)
UNSIGNED
NOT
NULL
DEFAULT
0
COMMENT
'单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值'
,
`
max_history_count
`
int
(
10
)
UNSIGNED
NOT
NULL
DEFAULT
0
COMMENT
'最大变更历史数量'
,
`
gmt_create
`
datetime
(
0
)
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
(
0
)
COMMENT
'创建时间'
,
`
gmt_modified
`
datetime
(
0
)
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
(
0
)
COMMENT
'修改时间'
,
PRIMARY
KEY
(
`
id
`
)
USING
BTREE
,
UNIQUE
INDEX
`
uk_group_id
`
(
`
group_id
`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_bin
COMMENT
=
'集群、各Group容量信息表'
ROW_FORMAT
=
Dynamic
;
DROP
TABLE
IF
EXISTS
`
his_config_info
`
;
CREATE
TABLE
`
his_config_info
`
(
`
id
`
bigint
(
64
)
UNSIGNED
NOT
NULL
,
`
nid
`
bigint
(
20
)
UNSIGNED
NOT
NULL
AUTO_INCREMENT
,
`
data_id
`
varchar
(
255
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NOT
NULL
,
`
group_id
`
varchar
(
128
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NOT
NULL
,
`
app_name
`
varchar
(
128
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
NULL
COMMENT
'app_name'
,
`
content
`
longtext
CHARACTER
SET
utf8
COLLATE
utf8_bin
NOT
NULL
,
`
md5
`
varchar
(
32
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
NULL
,
`
gmt_create
`
datetime
(
0
)
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
(
0
)
,
`
gmt_modified
`
datetime
(
0
)
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
(
0
)
,
`
src_user
`
text
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
,
`
src_ip
`
varchar
(
50
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
NULL
,
`
op_type
`
char
(
10
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
NULL
,
`
tenant_id
`
varchar
(
128
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
''
COMMENT
'租户字段'
,
PRIMARY
KEY
(
`
nid
`
)
USING
BTREE
,
INDEX
`
idx_gmt_create
`
(
`
gmt_create
`
)
USING
BTREE
,
INDEX
`
idx_gmt_modified
`
(
`
gmt_modified
`
)
USING
BTREE
,
INDEX
`
idx_did
`
(
`
data_id
`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_bin
COMMENT
=
'多租户改造'
ROW_FORMAT
=
Dynamic
;
DROP
TABLE
IF
EXISTS
`
permissions
`
;
CREATE
TABLE
`
permissions
`
(
`
role
`
varchar
(
50
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NOT
NULL
,
`
resource
`
varchar
(
255
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NOT
NULL
,
`
action
`
varchar
(
8
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NOT
NULL
,
UNIQUE
INDEX
`
uk_role_permission
`
(
`
role
`
,
`
resource
`
,
`
action
`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci ROW_FORMAT
=
Dynamic
;
DROP
TABLE
IF
EXISTS
`
roles
`
;
CREATE
TABLE
`
roles
`
(
`
username
`
varchar
(
50
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NOT
NULL
,
`
role
`
varchar
(
50
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NOT
NULL
,
UNIQUE
INDEX
`
idx_user_role
`
(
`
username
`
,
`
role
`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci ROW_FORMAT
=
Dynamic
;
DROP
TABLE
IF
EXISTS
`
tenant_capacity
`
;
CREATE
TABLE
`
tenant_capacity
`
(
`
id
`
bigint
(
20
)
UNSIGNED
NOT
NULL
AUTO_INCREMENT
COMMENT
'主键ID'
,
`
tenant_id
`
varchar
(
128
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NOT
NULL
DEFAULT
''
COMMENT
'Tenant ID'
,
`
quota
`
int
(
10
)
UNSIGNED
NOT
NULL
DEFAULT
0
COMMENT
'配额,0表示使用默认值'
,
`
usage
`
int
(
10
)
UNSIGNED
NOT
NULL
DEFAULT
0
COMMENT
'使用量'
,
`
max_size
`
int
(
10
)
UNSIGNED
NOT
NULL
DEFAULT
0
COMMENT
'单个配置大小上限,单位为字节,0表示使用默认值'
,
`
max_aggr_count
`
int
(
10
)
UNSIGNED
NOT
NULL
DEFAULT
0
COMMENT
'聚合子配置最大个数'
,
`
max_aggr_size
`
int
(
10
)
UNSIGNED
NOT
NULL
DEFAULT
0
COMMENT
'单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值'
,
`
max_history_count
`
int
(
10
)
UNSIGNED
NOT
NULL
DEFAULT
0
COMMENT
'最大变更历史数量'
,
`
gmt_create
`
datetime
(
0
)
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
(
0
)
COMMENT
'创建时间'
,
`
gmt_modified
`
datetime
(
0
)
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
(
0
)
COMMENT
'修改时间'
,
PRIMARY
KEY
(
`
id
`
)
USING
BTREE
,
UNIQUE
INDEX
`
uk_tenant_id
`
(
`
tenant_id
`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_bin
COMMENT
=
'租户容量信息表'
ROW_FORMAT
=
Dynamic
;
DROP
TABLE
IF
EXISTS
`
tenant_info
`
;
CREATE
TABLE
`
tenant_info
`
(
`
id
`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
COMMENT
'id'
,
`
kp
`
varchar
(
128
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NOT
NULL
COMMENT
'kp'
,
`
tenant_id
`
varchar
(
128
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
''
COMMENT
'tenant_id'
,
`
tenant_name
`
varchar
(
128
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
''
COMMENT
'tenant_name'
,
`
tenant_desc
`
varchar
(
256
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
NULL
COMMENT
'tenant_desc'
,
`
create_source
`
varchar
(
32
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
NULL
DEFAULT
NULL
COMMENT
'create_source'
,
`
gmt_create
`
bigint
(
20
)
NOT
NULL
COMMENT
'创建时间'
,
`
gmt_modified
`
bigint
(
20
)
NOT
NULL
COMMENT
'修改时间'
,
PRIMARY
KEY
(
`
id
`
)
USING
BTREE
,
UNIQUE
INDEX
`
uk_tenant_info_kptenantid
`
(
`
kp
`
,
`
tenant_id
`
)
USING
BTREE
,
INDEX
`
idx_tenant_id
`
(
`
tenant_id
`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_bin
COMMENT
=
'tenant_info'
ROW_FORMAT
=
Dynamic
;
DROP
TABLE
IF
EXISTS
`
users
`
;
CREATE
TABLE
`
users
`
(
`
username
`
varchar
(
50
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NOT
NULL
,
`
password
`
varchar
(
500
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NOT
NULL
,
`
enabled
`
tinyint
(
1
)
NOT
NULL
,
PRIMARY
KEY
(
`
username
`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci ROW_FORMAT
=
Dynamic
;
SET
FOREIGN_KEY_CHECKS
=
1
;
INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE);
INSERT INTO roles (username, role) VALUES ('nacos', 'ROLE_ADMIN');
1.3.2版本
b:解压并安装
tar -zxvf nacos-server-1.3.2.tar.gz
vim conf/application.properties
注意mysql5.7+连接url更改为:
jdbc:mysql:
上为单数据源。
cp cluster.conf.example cluster.conf
sh startup.sh -m standalone
cmd startup.cmd -m standalone
//clone代码
git clone https://github.com/alibaba/nacos.git
//进入nacos目录
cd nacos/
//跳过测试安装nacos
mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U
// 查看目录下的文件内容
ls -al distribution/target/
// 进入到bin目录下
cd distribution/target/nacos-server-$version/nacos/bin
// 解压文件
unzip nacos-server-$version.zip 或者 tar -xvf nacos-server-$version.tar.gz
//进入到nacos服务bin目录
cd nacos/bin
docker pull nacos/nacos-server
docker run --env MODE=standalone --name nacos -d -p 8848:8848 nacos/nacos-server
docker exec -it nacos bash
docker restart nacos
部分主要配置
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-boot.version>2.3.2.RELEASE</spring-boot.version>
<dubbo.version>2.7.3</dubbo.version>
<spring-cloud.version>Hoxton.SR8</spring-cloud.version>
<spring-cloud-alibaba.version>2.2.2.RELEASE</spring-cloud-alibaba.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>${spring-cloud-alibaba.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-bom</artifactId>
<version>${dubbo.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<exclusions>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
<exclusion>
<artifactId>fastjson</artifactId>
<groupId>com.alibaba</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
</dependencies>
server:
port: 8093
dubbo:
scan:
base-packages: com.test.learn.service
protocol:
name: dubbo
port: -1
registry:
address: spring-cloud://xx.xxx.xx.xx:8848
cloud:
subscribed-services: ''
provider:
cluster: failfast
retries: 1
timeout: 300000
token: true
dynamic: true
delay: -1
version: 1.3.2
filter: -exception
consumer:
check: false
validation: true
version: 1.3.2
spring:
application:
name: test-center
main:
allow-bean-definition-overriding: true
cloud:
nacos:
discovery:
server-addr: xx.xxx.xx.xx:8848
username: nacos
password: 123_nacos
namespace: d47b0fc3-8b21-4bef-8d20-bf4444714f16
config:
server-addr: xx.xxx.xx.xx:8848
file-extension: yaml
username: nacos
password: 123_nacos
context-path: /nacos
refresh: true
namespace: d47b0fc3-8b21-4bef-8d20-bf4444714f16
group: DEFAULT_GROUP
data-id: test-center-pro.yaml
配置部分参考
动态获取nacos信息参考
参考文章:
Nacos 服务注册与发现原理分析
https://blog.csdn.net/weixin_42739916/article/details/112984327
https://blog.csdn.net/xieqing_xq/article/details/105458887
https://blog.csdn.net/six_teen/article/details/109103848
https://blog.csdn.net/qq_43437874/article/details/108431799
文章目录一、配置数据源-mysql二、下载安装1.1 下载包安装(已验证)1.2 Github 上下载源码(未验证)1.3 docker安装(已验证)三、springCloud pom主要配置3.1 pom3.2 bootstrap.yaml部分配置3.3 nacos设置对应一、配置数据源-mysqla:配置数据库/* Navicat Premium Data Transfer Source Server : local Source Server Type : My
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>2.1.1..
版本说明
测试中发现,2.1.1.RELEASE版本的cloud会报未知用户的异常,2.2.1则没有,能够正常使用nacos的授权认证,只测试了这两个版本,最后为了版本对应上,使用了nacos建议的2.2.6版本:
<dependency&g
在实际项目开发=》测试=》上线中,服务配置文件是不可或缺的一部分,一般需要配置数据库等各个组件的配置信息,项目上线后,各个环境配置都不一样,Nacos提供了多环境下,读取不同配置文件的功能。
本次环境:
- Nacos 1.3.2
- spring boot 2.3.2.RELEASE
- spring cloud Hoxton.SR7
- cloud alibaba 2.2.1.RELEASE
参考此系列其他文档搭建Nacos注册中心及配置中心,在Nacos介面添加三个配置文件,分别
Nacos1.3.2已经完美的解决了权限问题,通过添加username和password来处理登录用户名和密码,但是存在一个问题,那就是用户名和密码存在特殊字符的时候会出现403,unknown user问题
username: nacos
password: nacos
NacosAuthManager.java具体代码位置如下:
private String resolveToken(HttpServletRequest request) throws AccessException {
2. 前言
观看此文应当具备一定的前后台分离的知识和了解MVC分层开发的概念,以及了解JWT(JsonWebToken),和无状态登录的概念,因笔者水平原因,有说的不对的地方,希望有大佬能够斧正。
3. 准备工作
首先为了模拟前后台分离开发过程中前台对后台的请求,我们使用Postman进行模拟,后台工程使用springboot整合SpringSecurity以及JWT(JsonWebToken)等,对于数据库的操作使用MyBat
文章目录Nacos SpringBoot Demonacos客户端鉴权及getConfig流程
在此我们假设你已经成功启动了nacos(无论是standalone亦或是cluster模式),并且开启了权限校验 nacos.core.auth.enabled=true,如果您对权限校验还不明了,可以翻看 从nacos的权限控制看nacos的配置热加载 。
这里我们开始使用客户端来开启nacos使用之旅。好吧,先提前告知,一切并不顺利,因为我们盲目的去除了客户端依赖的fastjson…
Nacos Spring
1. 下载Nacos Server:
您可以从Nacos官方GitHub仓库(https://github.com/alibaba/nacos/releases)下载最新版本的Nacos Server。
2. 解压Nacos Server:
将下载的Nacos Server压缩包解压到您选择的目录。
3. 启动Nacos Server:
在解压后的Nacos Server目录中,进入bin目录,并根据您的操作系统运行不同的启动脚本:
- Linux/Unix/Mac:执行startup.sh脚本
- Windows:执行startup.cmd脚本
4. 访问Nacos控制台:
打开浏览器,输入http://localhost:8848/nacos,即可访问Nacos控制台。
5. 配置Nacos服务:
在控制台中,使用默认的用户名和密码(均为nacos)登录。然后,您可以创建命名空间、配置服务等。
6. 集成Nacos到Spring Cloud项目:
在您的Spring Cloud项目的pom.xml文件中添加以下依赖关系:
```xml
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2.2.5.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- 其他依赖 -->
</dependencies>
然后,在您的Spring Cloud项目的application.properties(或application.yml)文件中添加以下配置:
```yaml
spring.cloud.nacos.config.server-addr=localhost:8848
这将指示您的应用程序连接到本地运行的Nacos Server。
7. 使用Nacos配置:
在您的Spring Cloud项目中,您可以使用@Value注解或@ConfigurationProperties注解来注入Nacos配置。
```java
@RestController
@RefreshScope // 当配置发生变化时刷新配置
public class MyController {
@Value("${my.property}")
private String myProperty;
// 其他代码
您还可以使用@NacosValue注解来动态获取配置。
这样,您就完成了Nacos的安装和配置以及集成到Spring Cloud项目中。您可以在Nacos控制台上管理和配置您的服务。
The connection to the server localhost:8080 was refused - did you specify the right host or port?解决
97649
The connection to the server localhost:8080 was refused - did you specify the right host or port?解决
叁零113: