likes
comments
collection
share

Springboot集成东方通等中间件打包和部署

作者站长头像
站长
· 阅读数 5

写在前面

在工作中,我们可能会遇到一些产品项目,要在不同的服务器部署,例如,在A项目部署,需要使用东方通中间件;在B项目部署,需要使用金蝶中间件;在C项目部署,则没有这样的要求,那就是用传统的tomcat中间件部署。

对于这些不同的中间件,那我们不应该是每次打包都去修改我们的pom.xml文件的吧?

如果每次都去改pom.xml文件,那就是太麻烦了,也有点鸡肋了!!!

请大家伙看到最后,这里提供一个比较好的解决方式!!!

Springboot集成东方通等中间件打包和部署

东方通整合说明

1.东方通相关jar包处理

解压下面的zip压缩包(这些文件,东方通那边的家伙会提供)

  • tongweb-embed-7.0.E.6_P6.zip
  • tongweb-spring-boot-reactor-7.0.E.6_P6.zip

分别执行installMavenJar.bat,即可将东方通相关依赖install安装到本地maven仓库。

分别执行deployMavenJar.bat,即可将东方通相关依赖deploy发布到公司nexus私服。

deployMavenJar.bat http://127.0.0.1:81/nexus/content/repositories/maven-releases releases

注:

1.tongweb相关的依赖已经发布到公司的nexus私服,能连上公司私服的,上面的安装和发布操作可以不用处理

2.tongweb-spring-boot-reactor,是gateway网关等netty服务需要用到,一般的springboot项目,可以不用处理

2.springboot项目处理

  • pom.xml依赖处理
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <!--排除springboot自带的tomcat依赖-->
    <exclusions>
        <exclusion>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <groupId>org.springframework.boot</groupId>
        </exclusion>
    </exclusions>
</dependency>
<!-- 添加tongweb-spring-boot-starter依赖 -->
<dependency>
    <groupId>com.tongweb.springboot</groupId>
    <artifactId>tongweb-spring-boot-starter-2.x</artifactId>
    <version>7.0.E.6_P6</version>
</dependency>
  • 指定license文件路径
# 指定tongweb东方通license文件路径
server.tongweb.license.type=file
server.tongweb.license.path=/home/root/license.dat

注:

1.License 存放路径支持“本地磁盘路径”和“classpath路径”,

2.jxbp底座,可以放入到nacos的nacos-config-dev.properties配置里面。

3.gateway网关项目处理

  • pom.xml依赖处理
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-bom</artifactId>
            <version>4.1.85.Final</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-core</artifactId>
            <version>3.4.23</version>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-webflux</artifactId>
    <!--排除netty相关依赖-->
    <exclusions>
        <exclusion>
            <artifactId>reactor-netty-http</artifactId>
            <groupId>io.projectreactor.netty</groupId>
        </exclusion>
        <exclusion>
            <artifactId>reactor-netty</artifactId>
            <groupId>io.projectreactor.netty</groupId>
        </exclusion>
        <exclusion>
            <artifactId>reactor-core</artifactId>
            <groupId>io.projectreactor</groupId>
        </exclusion>
        <exclusion>
            <artifactId>reactor-netty</artifactId>
            <groupId>io.projectreactor.ipc</groupId>
        </exclusion>
    </exclusions>
</dependency>
<!-- 添加tongweb-spring-boot-reactor-starter依赖 -->
<dependency>
    <groupId>com.tongweb</groupId>
    <artifactId>tongweb-spring-boot-reactor-starter</artifactId>
    <version>7.0.E.6_P6</version>
</dependency>
  • 指定license文件路径
# 指定tongweb东方通license文件路径
server.tongweb.license.type=file
server.tongweb.license.path=classpath:license.dat

注:

1.License 存放路径支持“本地磁盘路径”和“classpath路径”,

2.jxbp底座,可以放入到nacos的nacos-config-dev.properties配置里面。

4.相关参数配置修改

# tomcat 调优 
# 等待连接数
server.tomcat.accept-count=1000
# 最大连接数
server.tomcat.max-connections=1000
# 最大线程数量
server.tomcat.max-threads=1000
# 最小线程数
server.tomcat.min-spare-threads=10

改成

# tomcat 调优 
# 等待连接数
server.tongweb.accept-count=1000
# 最大连接数
server.tongweb.max-connections=1000
# 最大线程数量
server.tongweb.max-threads=1000
# 最小线程数
server.tongweb.min-spare-threads=10

5.mvn打包指定pom.xml

一般来说,一个项目只需有一个pom.xml文件即可。

但是有时候,可能需要整合金蝶东方通这些服务器中间件时,就需要将springboot内置的tomcat替换相应的中间件,这时虽然可以使用同一个pom.xml文件,但是每次打包都得改pom.xml,这样使用起来很不方便。

这时,我们可以为不同的中间件创建对应的pom.xml文件。

例如:金蝶,我们可以创建一个pomJd.xml文件;东方通,我们可以创建一个pomTw.xml文件;本地测试时编译项目使用的还是pom.xml文件。

当我们想打包东方通相关的jar包时,可以使用下面的命令:

#指定pom文件打包:
mvn clean && mvn package -f pomTw.xml -Dmaven.test.skip=true

这样做的目的,是为了可以动态的切换打包的服务器中间件,也比较灵活。也能提交到svn中进行相关的记录。

pomTw.xml和原来的pom.xml,基本上是一样,只是加入了tongweb相关的依赖和去掉tomcat的依赖。


好了,以上就是我个人的实操了。可能有些不对,大家伙,轻点喷!!!

个人理解,可能也不够全面,班门弄斧了。

好了,今天就先到这里了!!!^_^

如果觉得有收获的,帮忙点赞、评论、收藏一下,再走呗!!!

Springboot集成东方通等中间件打包和部署

转载自:https://juejin.cn/post/7329206771565625371
评论
请登录