当前位置:   article > 正文

东方通TongWeb结合Spring-Boot使用_tongweb springboot

tongweb springboot

一、概述

信创需要;

原状:原来的服务使用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>
  • 1
  • 2
  • 3
  • 4
  • 5

-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>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28

如果需要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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

配置了 授权码 的类型和路径,路径推荐放到项目的tongweb文件夹里面:
在这里插入图片描述
注意:授权码的版本和我们依赖的jar包的版本一定要保持一致,否则会报如下错误:
在这里插入图片描述

2.4 启动验证

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

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/815952
推荐阅读
相关标签
  

闽ICP备14008679号