汕尾海湾 发表于 2024-7-11 22:26:00

东方通TongWeb联合Spring-Boot使用

一、概述

信创须要;
原状:原来的服务使用springboot框架,自带的web容器是tomcat,打成jar包启动;
需求:使用东方通tongweb来更换tomcat容器;
二、更换步骤

2.1 准备

获取到TongWeb7.0.E.6_P7嵌入版 这个文件,文件内容有相关对应的依赖包,可以根据须要来安装到当地或者上传到对应的maven堆栈;
https://img-blog.csdnimg.cn/direct/f449220439274e20b441daa9cf5b18b6.png
这个文件内里,也有对应的安装/上传依赖的执行文件,不消自己一个一个安装上传了:
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-gmsslJSP支持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文件夹内里:
https://img-blog.csdnimg.cn/direct/aa197ae2b8ba454f9d39a107c72e0ae0.png
注意:授权码的版本和我们依赖的jar包的版本肯定要保持同等,否则会报如下错误:
https://img-blog.csdnimg.cn/direct/6c8409ed9920427bb2d3a2ce013556e7.png
2.4 启动验证

启动乐成:
https://img-blog.csdnimg.cn/direct/00ee139d225f4d40938b95484d0e2254.png
验证接口,请求乐成:
https://img-blog.csdnimg.cn/direct/231bfc9f4cf8475f964b946b0ec4e39b.png

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: 东方通TongWeb联合Spring-Boot使用