一、概述
信创需要;
原状:原来的服务使用springboot框架,自带的web容器是tomcat,打成jar包启动;
需求:使用东方通tongweb来替换tomcat容器;
二、替换步骤
2.1 准备
获取到TongWeb7.0.E.6_P7嵌入版 这个文件,文件内容有相关对应的依赖包,可以根据需要来安装到本地或者上传到对应的maven仓库;

这个文件里面,也有对应的安装/上传依赖的执行文件,不用自己一个一个安装上传了:
2.2 修改pom.xml
spring-boot-starter-web这个依赖默认使用的是spring-boot-starter-tomcat 这个依赖;我们只需要排除这个依赖,然后再把TongWeb对应的starter加入进来即可;
由于我的spring-boot使用的是2.*.* 版本,所以我们使用的依赖:
<dependency>
<groupId>com.tongweb.springboot</groupId>
<artifactId>tongweb-spring-boot-starter-2.x</artifactId>
<version>7.0.E.6_P7</version>
</dependency>
-2.x是和spring-boot的大版本对应:spring-boot版本为1.*.* 那么使用
tongweb-spring-boot-starter-1.xspring-boot版本为2.*.* 那么使用
tongweb-spring-boot-starter-2.xspring-boot版本为3.*.* 那么使用
tongweb-spring-boot-starter-3.x
修改后的pom.xml:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.tongweb.springboot</groupId>
<artifactId>tongweb-spring-boot-starter-2.x</artifactId>
<version>7.0.E.6_P7</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
如果需要tongweb容器集成其他的功能,需要添加额外的依赖如:
| 功能 | 依赖 |
|---|---|
| 集成JDBC | tongweb-spring-boot-data-jdbc-starter |
| 集成Websocket | tongweb-spring-boot-websocket |
| 集成gmssl安全通信库(国密) | tongweb-gmssl |
| JSP支持 | tongweb-jsp |
2.3 配置application.yml
配置属性server.tongweb.*
server:
port: 9099
tongweb:
license:
type: file
path: classpath:tongweb/license 7.0.E嵌入式版-0506.dat
配置了 授权码 的类型和路径,路径推荐放到项目的tongweb文件夹里面:

注意:授权码的版本和我们依赖的jar包的版本一定要保持一致,否则会报如下错误:

2.4 启动验证
启动成功:

验证接口,请求成功:

本文档介绍了如何在信创背景下,将Spring-Boot应用中的Tomcat容器替换为东方通TongWeb。详细阐述了替换步骤,包括准备TongWeb依赖、修改pom.xml、配置application.yml以及启动验证,确保服务正常运行。
402

被折叠的 条评论
为什么被折叠?



