替换Tomcat中间件
Tomcat是什么
Apache Tomcat (called “Tomcat” for short) is a free and open-source implementation of the Jakarta Servlet, Jakarta Expression Language, and WebSocket technologies.[2] It provides a “pure Java” HTTP web server environment in which Java code can also run. Thus it is a Java web application server, although not a full JEE application server.
Tomcat is developed and maintained by an open community of developers under the auspices of the Apache Software Foundation, released under the Apache License 2.0 license.
Spring Cloud剔除tomcat
<!--集成springmvc框架 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<!-- 适配宝兰德,移除tomcat-->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
<optional>true</optional>
</dependency>
引入宝兰德Application Server
宝蓝德中间件的获取目前在官网是不能直接下载的,下载会提示你联系管理员;我是通过官网联系到客服,说明来意后,当地的销售人员联系我,并发送了相关中间件程序;
- 百度网盘提取码:564x
- 将需要的相关jar包install到本地的maven仓库,目前我只是用到了bes-lite-spring-boot-2.x-starter-9.5.5.003.jar和bes-websocket-9.5.5.003.jar
- install命令
mvn install:install-file -Dfile=./bes-lite-spring-boot-2.x-starter-9.5.5.003.jar -DgroupId=com.bes.appserv-web -DartifactId=bes-lite-spring-boot-2.x-starter -Dversion=9.5.5.003 -Dpackaging=jar
mvn install:install-file -Dfile=./bes-websocket-9.5.5.003.jar -DgroupId=com.bes.appserv-web -DartifactId=bes-websocket -Dversion=9.5.5.003 -Dpackaging=jar
- 在pom文件中引入打包的库文件
<!-- 添加宝兰德依赖-->
<dependency>
<groupId>com.bes.appserv-web</groupId>
<artifactId>bes-lite-spring-boot-2.x-starter</artifactId>
<version>9.5.5.003</version>
</dependency>
<dependency>
<groupId>com.bes.appserv-web</groupId>
<artifactId>bes-websocket</artifactId>
<version>9.5.5.003</version>
</dependency>
- 引入成功后,Tomcat相关的import需要做适当调整。
打包运行
目前项目就网关和系统模块两个模块,打包后正常启动
- 网关微服务
spring gateway目前是不依赖tomcat的,所以无需调整; - 系统微服务
日志输出这部分内容就说明宝兰德中间件正确启动了;
授权
宝蓝德官方给出的授权方案一共有6种:
- 通过系统属性指定License文件所在目录
- 通过系统属性指定License文本数据
- 通过环境变量指定License文件所在目录
- 通过环境变量指定License文本数据
- 指定BES根目录
- 替换jar包中的License文件
授权方案6是将介质文件bes‑lite‑spring‑boot‑2.x‑starter.jar解压到目录bes‑lite‑starter中
jar -xvf bes‑lite‑spring‑boot‑2.x‑starter.jar -C ./bes‑lite‑starter/
使用正式版的bes.lic.txt替换掉bes‑lite‑starter目录中的bes.lic.txt文件,进入bes‑lite‑starter目录执行
以下打包命令:
jar -cvf0m bes-lite-spring-boot-2.x-starter.jar META-INF/MANIFEST.MF *
注:jar命令选项0表示不压缩。