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>

六、启动成功

相关推荐
IT_陈寒6 分钟前
Vue的响应式更新有时候真的不听话
前端·人工智能·后端
weixin_3993806933 分钟前
TongWeb7.0.4.9M11一键安装脚本(by sy)
java·spring
向生1 小时前
Ubuntu Caddy 保姆级完整教程
后端
tntxia1 小时前
Docker权限的问题
后端
明月_清风1 小时前
看完这段关于"全插件化架构"的技术分析后,我整理了一份笔记
前端·后端
摇滚侠2 小时前
《SpringBoot 3:入门与应用实战》第 7 章 AOP 思想与实现 阅读笔记 14
spring boot·笔记·后端
她的男孩2 小时前
我把管理系统接给AI,它改条数据都要先问我
java·后端·架构
元界metalite2 小时前
SpringBoot分页接口怎么设计-pageSize不设上限会发生什么
后端
IT爱学堂3 小时前
Go开发疑难杂症终结者通关指南
后端
大勇前进4 小时前
从10分钟到10秒:一个真实慢查询的SQL Server优化全记录
后端