SpringCloud——国产化改造,项目对接 TongWeb 嵌入版

文章目录

  • 一、目标
  • 二、安装依赖
  • 三、版本控制
  • [四、Gateway 适配](#四、Gateway 适配)
    • [1. 添加依赖](#1. 添加依赖)
    • [2. 排除依赖](#2. 排除依赖)
  • [五、spring-boot 适配](#五、spring-boot 适配)
    • [1. 直接排除 tomcat](#1. 直接排除 tomcat)
    • [2. 引入 tongweb 依赖](#2. 引入 tongweb 依赖)
  • 六、启动成功

一、目标

使用内嵌式 TongWeb 只需要改造项目的 pom 文件即可,目标就是去除 Tomcat ,替换为 TongWeb。

二、安装依赖

bash 复制代码
TongWeb Vx.x.xx/
├── TongWeb Vx.x.xx
├── TongWebx.x.x.x_xx/
│   ├── 安装工程介质/
│   │   ├── tongweb-embed-x.x.x.x_xx/
│   │   │   ├── lib/
│   │   │   └── installMavenJar.bat
│   │   │   └── ...
│   │   ├── ...
│   ├── 示例工程/
│   ├── 用户手册与配置示例/

Windows 环境直接执行上面展示的那个 installMavenJar.bat 就可以把嵌入式 TongWeb 的依赖安装到本地 Maven 仓库。

三、版本控制

xml 复制代码
<properties>
······
<tongweb.version.updator>8.0.E.8</tongweb.version.updator>
······
</properties>
 
<dependencyManagement>
 <!-- 确保在spring-boot/cloud-dependencies前面 -->
   <dependency>
      <groupId>com.tongweb</groupId>
      <artifactId>tongweb-embed-dependencies</artifactId>
      <version>${tongweb.version.updator}</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
    ······
</dependencyManagement>

四、Gateway 适配

1. 添加依赖

xml 复制代码
<dependency>
  <groupId>com.tongweb.springboot</groupId>
  <artifactId>tongweb-spring-boot-starter-2.x</artifactId>
</dependency>
<dependency>
  <groupId>com.tongweb</groupId>
  <artifactId>tongweb-spring-boot-reactor-starter</artifactId>
  <exclusions>
    <exclusion>
      <groupId>io.netty</groupId>
      <artifactId>netty-resolver-dns-native-macos</artifactId>
    </exclusion>
  </exclusions>
</dependency>

2. 排除依赖

原生依赖排除相关内容

xml 复制代码
<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-gateway</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>io.projectreactor.ipc</groupId>
                    <artifactId>reactor-netty</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.projectreactor.addons</groupId>
                    <artifactId>reactor-extra</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.projectreactor.netty</groupId>
                    <artifactId>reactor-netty-http</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.projectreactor.netty</groupId>
                    <artifactId>reactor-netty</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.projectreactor</groupId>
                    <artifactId>reactor-core</artifactId>
                </exclusion>
            </exclusions>
</dependency>
<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>io.projectreactor.netty</groupId>
                    <artifactId>reactor-netty-http</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.projectreactor.netty</groupId>
                    <artifactId>reactor-netty</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.projectreactor</groupId>
                    <artifactId>reactor-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.projectreactor.ipc</groupId>
                    <artifactId>reactor-netty</artifactId>
                </exclusion>
            </exclusions>
</dependency>

五、spring-boot 适配

1. 直接排除 tomcat

xml 复制代码
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
  <exclusions>
    <!--排除tomcat依赖-->
    <exclusion>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-tomcat</artifactId>
    </exclusion>
  </exclusions>
</dependency>

2. 引入 tongweb 依赖

xml 复制代码
<dependency>
   <groupId>com.tongweb.springboot</groupId>
   <artifactId>tongweb-spring-boot-starter-2.x</artifactId>
</dependency>

六、启动成功

相关推荐
To_OC7 小时前
手写 AI 编程 Agent 的命令执行工具:我被 child_process 坑出来的实战经验
后端·node.js·agent
逝水无殇9 小时前
C# 异常处理详解
开发语言·后端·c#
考虑考虑12 小时前
Sentinel安装
java·后端·微服务
IT_陈寒12 小时前
SpringBoot自动配置失灵?你可能忘了这个关键注解
前端·人工智能·后端
碎碎念_49212 小时前
SpringBoot + Vue 前后端分离从 0 到 1 完整环境配置流程
vue.js·spring boot·后端
逝水无殇12 小时前
C# 文件的输入与输出详解
开发语言·数据库·后端·c#
YIAN13 小时前
从手写 Agent 工具到 MCP 协议:一文搞懂大模型跨进程跨语言工具调用
后端·agent·mcp
小兔崽子去哪了13 小时前
Docker 删除镜像后磁盘空间没有释放?
后端·docker·容器
高明珠13 小时前
麒麟 V10 SP1 排查实录:ttyS5 每 10 秒莫名收到一批报文,元凶是 eGTouchD
后端
卷无止境13 小时前
Python FFI 技术深度解析:ctypes、cffi 与 pybind11 的性能差异与实践挑战
后端·python