东方通TongWeb结合Spring-Boot使用

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

一、概述

信创需要;

原状:原来的服务使用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.x

spring-boot版本为2.*.* 那么使用

tongweb-spring-boot-starter-2.x

spring-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容器集成其他的功能,需要添加额外的依赖如:

功能依赖
集成JDBCtongweb-spring-boot-data-jdbc-starter
集成Websockettongweb-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 启动验证

启动成功:
在这里插入图片描述

验证接口,请求成功:
在这里插入图片描述

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

象话

打赏犹如太阳穴的枪口

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值