springboot+feign+nacos+seata+docker整合踏坑实录

一、版本

springboot:2.7.2

feign:3.1.5

jdk:19

seata:1.5.2

nacos:V2.1.2

二、docker部署

1.配置文件实列

配置说明

下述配置为该当前最新镜像,seata的配置不需要区分成网上所说的registry.conffile等配置文件。

nacosseata的配置文件可先启动容器之后从容器中拿出配置文件再做响应的修改。

docker-compose.yml配置文件:

version: '3'
services:two_mysql:image: mysql:8.0.29container_name: two_mysqlports:- 3316:3306environment:MYSQL_ROOT_PASSWORD: root #设置root帐号密码TZ: Asia/Shanghaivolumes:- F:\docker-install-path\native_volume\mysql\mysql_data_db:/var/lib/mysql #数据文件挂载- F:\docker-install-path\native_volume\mysql\mysql_log:/var/log/mysql #日志文件挂载- F:\docker-install-path\native_volume\mysql\mysql_config\my.cnf:/etc/my.cnfnetworks:rmq:aliases:- two_mysql seata_server:image: seataio/seata-server:1.6.0container_name: seata_serverdepends_on:- nacos_serverports:- 8091:8091- 7091:7091volumes:# 假设我们通过docker cp命令把资源文件拷贝到相对路径`./seata-server/resources`中- F:\docker-install-path\native_volume\seata\resources\:/seata-server/resources/networks:rmq:aliases:- seata_servernacos_server:image: nacos/nacos-server:v2.1.2container_name: nacos_serverdepends_on: - two_mysqlenvironment:- MODE=standaloneports:- 8848:8848- 9848:9848- 9849:9849volumes:# 假设我们通过docker cp命令把资源文件拷贝到相对路径`./seata-server/resources`中- F:\docker-install-path\native_volume\nacos\conf:/home/nacos/conf- F:\docker-install-path\native_volume\nacos\data:/home/nacos/datanetworks:rmq:aliases:    - nacos_server
networks:rmq:name: rmqdriver: bridge

nacos挂载出来的配置文件application.properties

server.servlet.contextPath=/nacos
server.port=8848spring.datasource.platform=mysql
server.error.include-message=ALWAYSdb.num=1db.url.0=jdbc:mysql://two_mysql:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.user=root
db.password=rootmanagement.metrics.export.elastic.enabled=falsemanagement.metrics.export.influx.enabled=falseserver.tomcat.accesslog.enabled=trueserver.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}iserver.tomcat.basedir=/nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**nacos.core.auth.system.type=nacos
# 该配置设置false取消nacos权限验证
nacos.core.auth.enabled=falsenacos.core.auth.enable.userAgentAuthWhite=falsenacos.core.auth.server.identity.key=serverIdentity
nacos.core.auth.server.identity.value=securitynacos.core.auth.default.token.expire.seconds=18000nacos.core.auth.default.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789nacos.istio.mcp.server.enabled=falsespring.cloud.nacos.username=nacos
spring.cloud.nacos.password=nacos

seata-server挂载配置文件application.yml

#  Copyright 1999-2019 Seata.io Group.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.server:port: 7091spring:application:name: seata-serverlogging:config: classpath:logback-spring.xmlfile:path: ${user.home}/logs/seataextend:logstash-appender:destination: 127.0.0.1:4560kafka-appender:bootstrap-servers: 127.0.0.1:9092topic: logback_to_logstashconsole:user:username: seatapassword: seataseata:config:# support: nacos, consul, apollo, zk, etcd3type: nacosnacos:server-addr: 192.168.3.29:8848namespace: test01group: SEATA_GROUPusername: nacospassword: nacosregistry:# support: nacos, eureka, redis, zk, consul, etcd3, sofatype: nacosnacos:application: seata-serverserver-addr: 192.168.3.29:8848group: SEATA_GROUPnamespace: test01cluster: defaultusername: nacospassword: nacosstore:# support: file 、 db 、 redismode: dbdb:datasource: druiddb-type: mysqldriver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://two_mysql:3306/seata?useUnicode=true&characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=trueuser: rootpassword: root
#  server:
#    service-port: 8091 #If not configured, the default is '${server.port} + 1000'security:secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017tokenValidityInMilliseconds: 1800000ignore:urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/api/v1/auth/login

2.问题记录

1.当用docker-compose启动该实列seata-server启动会失败,原因是因为depends_on配置的编排虽然等待了nacos容器的启动但是nacos实列还未完全启动成功,所以导致seata-server启动失败。

解决方案为重新再次启动一次seata-server

2.docker-compose.yml文件中个镜像启动配置一定配置好container_name

3.seata-serverapplication.yml配置文件注册中心地址一定使用宿主机ip,不要使用docker配置的域名,会导致注册不上去。报**failed to req API:/nacos/v1/ns/instance after all servers([nacos_server:8848]) **错误!

三、springboot客户端配置

启动异常问题:

1.异常信息: org/springframework/boot/Bootstrapper,缺少spring-cloud-starter-bootstrap包,引入即可;

2.如果是springboot3.0.0版本讲读不到nacos的配置文件所以最好降下springboot的版本;

3.启动 Unable to make field protected java.lang.reflect.InvocationHandler java.lang.reflect.Proxy.h accessible: module java.base does not "opens java.lang.reflect" to unnamed module @3eb738bb Unable to make field protected java.lang.reflect.InvocationHandler java.lang.reflect.Proxy.h accessible: module java.base does not "opens java.lang.reflect" to unnamed module @3eb738bb,需要设置启动参数--add-opens java.base/java.lang.reflect=ALL-UNNAMED如果是报错其它包就换其它包
4.网络不通问题,宿主机无法pingdocker容器中的ip,报错异常信息为can not register RM,err:can not connect to services-server.。解决方案参考http://t.csdn.cn/taJtC

application.yml配置

server:port: 1210
spring:jpa:hibernate:ddl-auto: updateshow-sql: truedatasource:url: jdbc:mysql://localhost:3316/seata-client1?useUnicode=true&characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=trueusername: rootpassword: rootdriver-class-name: com.mysql.cj.jdbc.Driverapplication:name: seata-client1main:allow-circular-references: truecloud:nacos:discovery:server-addr: 127.0.0.1:8848group: SEATA_GROUPusername: nacospassword: nacosnamespace: test01alibaba:seata:tx-service-group: default_tx_group
seata:application-id: ${spring.application.name}
#  tx-service-group: seataClient1enabled: trueconfig:type: nacosnacos:server-addr: 127.0.0.1:8848group: SEATA_GROUPusername: nacospassword: nacosnamespace: test01registry:type: nacosnacos:server-addr: 127.0.0.1:8848group: SEATA_GROUPusername: nacospassword: nacosnamespace: test01
logging:level:root: info

代码仓库地址: https://gitee.com/wdx-7929/seata-test1?_from=gitee_search

springboot+feign+nacos+seata+docker整合踏坑实录相关推荐

  1. springboot+openFeign+nacos+seata开发实战

    本文来编写一个程序实例说下seata的使用,使用的分布式环境是openFeign整合nacos.如何想要使用dubbo整合nacos也是同样的道理,只要注意openFeign和dubbo在使用上的细微 ...

  2. SpringBoot+Nacos+Seata实现Dubbo分布式事务管理

    SpringBoot+Nacos+Seata实现Dubbo分布式事务管理 https://www.shangmayuan.com/a/a3ba056126ba45db9b8dfd5b.html 源码下 ...

  3. Springboot+nacos+seata实现简单分布式事务经验分享:二

    Springboot+nacos+seata实现简单的分布式事务 上一篇文章把三个服务都注册进nacos中了,这次就开始写业务代码 首先先创建三个数据库,每个数据库都需要有一张记录表,一张回滚表 or ...

  4. DB数据源之SpringBoot+MyBatis踏坑过程(三)手工+半自动注解配置数据源与加载Mapper.xml扫描...

    DB数据源之SpringBoot+MyBatis踏坑过程(三)手工+半自动注解配置数据源与加载Mapper.xml扫描 liuyuhang原创,未经允许禁止转载    系列目录连接 DB数据源之Spr ...

  5. spring中怎么访问MySQL过程_DB数据源之SpringBoot+MyBatis踏坑过程(六)mysql中查看连接,配置连接数量...

    DB数据源之SpringBoot+MyBatis踏坑过程(六)mysql中查看连接,配置连接数量 liuyuhang原创,未经允许禁止转载 系列目录连接 1.环境说明 mysql5.0以上版本. wi ...

  6. springboot与docker整合

    一.springboot与docker整合 a.创建Dockerfile FROM java MAINTAINER "Wing"<1561815137@qq.com> ...

  7. springboot+openFeign+nacos开发实战

    前面说了dubbo+nocas开发实战,现在来说下springboot+openFeign+nacos开发实战. 文章目录 什么是Feign Nacos环境准备 Nacos与openFegin整合 项 ...

  8. docker入门,镜像,容器,数据卷,dockerfile,docker网络,springboot微服务打包docker镜像[狂神yyds]

    docker学习大纲 docker概述 docker安装 docker命令 镜像命令 容器命令 操作命令 - docker镜像 容器数据卷 dockerfile docker网络原理 IDEA整合do ...

  9. springboot项目打包为docker镜像并上传nexus私服

    springboot项目docker打包镜像上传Nexus私服 1.springboot项目打包为docker镜像并上传nexus私服 1.0. 必要条件 1.1.开启docker远程访问 1.2.配 ...

最新文章

  1. Drill storage plugin实现原理分析
  2. wmic 获取计算机ip,【已解决】xp系统下,受限用户如何用批处理在不使用wmic获取多个网卡的IP地址?...
  3. Java微框架Spring Boot 运行原理深入解读
  4. Remoting实例(同为客户端服务端)
  5. execl中设置的格式无法实现
  6. 《鸿蒙理论知识02》HarmonyOS开发平台和工具
  7. Android内存泄漏分析及调试
  8. PHP获取一篇文章内容中的全部图片,并下载
  9. 50多款51单片机程序源码原理图编程源代码
  10. 2018第九届蓝桥杯B组决赛题解第四题 调手表(简单的dp)
  11. 现代战争——僵尸网络的历史(上篇)
  12. MATLAB当中一些简单的数值分析函数总结
  13. Ubuntu系统镜像盘ISO:各版本大全、国内网速下载地址(阿里云)
  14. 小游戏---2048
  15. win7单机计算机就可打开,月影传说单机版电脑版
  16. 【课件整理复习】第十一章 图像识别与文字处理
  17. 江苏限额申报|2022年省级企业工程技术研究中心项目申报
  18. python计算机视觉--基于(BOW)的图像检索与识别
  19. 【Python画图01】一张图上两条线,坐标图例设置
  20. 使用小程序制作一个电子木鱼,功德+1

热门文章

  1. 音视频开发---M3U8 https://www.jianshu.com/p/e97f6555a070
  2. Whatsns内容付费seo优化带采集和熊掌号运营问答系统
  3. 服务器设置header返回信息,http服务器header返回时间问题
  4. 2017-11-11 今天的工作任务
  5. 《微信公众平台开发最佳实践》——导读
  6. 亿嘉和机器人上市了吗_年科研投入近10% 亿嘉和誓做“世界一流机器人公司”...
  7. 几种常用网络请求汇总
  8. oralce字符串函数
  9. microsoft edge 打开垃圾网页
  10. js 第1步:随机生成json对象,格式为:“[[{“text“:XXXX},{“text“:XXXX}],[{“text“:XXXX},{“text“:XXXX},{“text“:XXXX}]]“