springcloud+nacos+dubbo+seata微服务
搭建nacos服务注册、配置中心
nacos详细解说:https://nacos.io/zh-cn/docs/quick-start.html
1、下载对应nacos版本,可从最新稳定版本下载 nacos-server-$version.zip 包
unzip nacos-server- v e r s i o n . z i p 或 者 t a r − x v f n a c o s − s e r v e r − version.zip 或者 tar -xvf nacos-server- version.zip或者tar−xvfnacos−server−version.tar.gz
cd nacos/bin
2、简单启动nacos服务器(在bin目录下操作)
Linux/Unix/Mac系统
启动命令(standalone代表单机模式运行,非集群模式):
sh startup.sh -m standalone
若使用的ubuntu系统,或者运行脚本报错提示[[符号找不到,可尝试如下运行:
bash startup.sh -m standalone
Windows系统
启动命令(standalone代表单机模式运行,非集群模式):
cmd startup.cmd -m standalone
可以新建个脚本文件,如: ubuntu.sh/nacos_local.bat
内容写:bash startup.sh -m standalone/ cmd startup.cmd -m standalone
服务注册&发现和配置管理
服务注册
curl -X POST ‘http://127.0.0.1:8848/nacos/v1/ns/instance?serviceName=nacos.naming.serviceName&ip=20.18.7.10&port=8080’
服务发现
curl -X GET ‘http://127.0.0.1:8848/nacos/v1/ns/instance/list?serviceName=nacos.naming.serviceName’
发布配置
curl -X POST “http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&group=test&content=HelloWorld”
获取配置
curl -X GET “http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&group=test”
关闭服务器
Linux/Unix/Mac
sh shutdown.sh
Windows
cmd shutdown.cmd
或者双击shutdown.cmd运行文件。
还可以使用DB配置,这个得自己再研究,要改application.properties,还得执行sql文件,都在conf目录下
3、访问:http://IP地址:8848/nacos/index.html(账号:nacos、密码nacos)
如下图的成功页面:
搭建springcloud微服务(详细步骤省略。。。)
一共3个子项目、父级pom依赖:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<modules>
<module>thinkd-rpc_affair</module> LCN事务TM协调者
<module>dubbo_serve</module>
<module>thinkd-adminmanage</module>
<module>thinkd-operators</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-cloud.version>Hoxton.SR8</spring-cloud.version>
<java.version>1.8</java.version>
<projectlombok.version>1.18.12</projectlombok.version>
<fastjson.version>1.2.73</fastjson.version>
<!-- 数据库版本 -->
<mysql.version>5.1.48</mysql.version>
<druid.version>1.1.20</druid.version>
<mybatis.version>2.1.0</mybatis.version>
<!-- nacos注册中心springcloud依赖 -->
<nacos.cloud.version>2.2.1.RELEASE</nacos.cloud.version>
<!-- dubbo依赖springcloud配置 -->
<dubbo.cloud.version>2.2.1.RELEASE</dubbo.cloud.version>
</properties>
<dependencies>
<!--<!– springCloud客户端 netflix组件注册 –>-->
<!--<dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-openfeign</artifactId>-->
<!--</dependency>-->
<!-- DRUID 数据库 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${
mysql.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<!--<artifactId>druid-spring-boot-starter</artifactId>-->
<version>${
druid.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${
mybatis.version}</version>
</dependency>
<!-- nacos 注册中心springcloud配置 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>${
nacos.cloud.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>${
nacos.cloud.version}</version>
</dependency>
<!-- 整合基本依赖jar包 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${
projectlombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${
fastjson.version}</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<