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>

六、启动成功

相关推荐
郑州光合科技余经理3 小时前
代驾系统架构拆解:订单链路、权限组织与私有化源码交付
开发语言·后端·算法·架构·系统架构·uni-app·php
hboot5 小时前
AI工程师第六课 - RAG检索增强生成
后端·langchain·llm
mldong6 小时前
jeeflow:98KB 的工作流引擎长什么样
后端
Pluchon7 小时前
Java个人综合项目——萌部落社区V2.0
java·python·spring·spring cloud·postman·idea
她说可以呀8 小时前
Spring-ai-alibaba文生图
java·人工智能·spring
程序员cxuan9 小时前
速度太快了!本地可以跑 DeepSeek-V4-Flash 了
人工智能·后端·程序员
阿祖zu10 小时前
芝士就是力量!开源私有化部署与 GitHub 双向同步的个人知识笔记 App
前端·后端·ios
不才不才不不才10 小时前
Spring 源码系列(16): doDispatch 全流程——一次请求的主干链路
java·后端·spring
IT_陈寒10 小时前
SpringBoot自动配置失效?这个隐藏配置坑了我一整晚
前端·人工智能·后端
搜狐技术产品小编202310 小时前
告别“黑盒”与误判:如何用“多智能体对抗辩论”重构内容安全审核系统
后端·多agent