springboot+vue项目在国产机东方通部署详细教程!

文章目录

一、部署东方通TongWeb

  1. 上传安装包:TongWeb7.0.4.9_Enterprise_Linux.tar.gz

  2. 解压:tar -xvf TongWeb7.0.4.9_Enterprise_Linux.tar.gz

  3. 证书:提供的license 文件是企业版的,企业版支持以 war 包方式部署应用。 解压后,将license.dat 放在安装的根目录下

  4. 进入bin目录启动:./startserverbg.sh

  5. 访问页面:http://ip:9060/console

    ps:默认账号密码thanos/thanos123.com,首次登陆需要修改账号密码

二、部署TongHttpServer

ps1:TongHttpServer实际上就是nginx在国产机上的替代品,除了名字意外,其他的原理跟nginx是一样的

pa2:nginx也可以直接部署在国产机上,且操作比部署linux上简单。即不需要安装gcc等插件,直接下载,解压,安装,编译即可!详情可见https://blog.csdn.net/weixin_40496191/article/details/121028500

  1. 由于我是拿linux验证的,国产机其实也差不多,我这里使用的安装包是:TongHttpServer_6.0.0.2_x86_64.tar.gz

  2. 解压:tar -xvf TongHttpServer_6.0.0.2_x86_64.tar.gz

  3. 将证书文件license.dat拷贝到TongHttpServer的解压文件夹里面

  4. 在THS/bin目录下,执行命令查看license信息:./start.sh -l

  5. 启动指令:./start.sh

  6. 停止指令:./start.sh stop

  7. 配置文件:/TongHttpServer/THS/conf/httpserver.conf

  8. 使用:跟nginx的使用方法一样。相关反向代理直接在httpserver.conf,然后重启TongHttpServer即可!

三、springboot多模块后端打包

  1. 需要改的配置

    1)主要启动模块pom文件添加配置

    java 复制代码
    <packaging>war</packaging>

    2)启动类添加SpringApplicationBuilder方法

    java 复制代码
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(WebApplication.class);
    }

    剩下的就是解决bug

  2. 遇到的坑1:在filter过滤器引入变量的时候,使用@Value导致引入的变量都为null

    ps:所有的filter类有涉及@Value的都要改,因为东方通中,filter加载在spring之前,都需要改成静态加载方式才能够读取到

    java 复制代码
    public static String whiteUrl;
    
    @Value("${FormXssFilter.url}")
    public void setWhiteUrl(String whiteUrl) {
       FormXssFilter.whiteUrl=whiteUrl;
    }
  3. 遇到的坑2:遇到ZonedDate转换错误的,需要加下以下这个类

    java 复制代码
    package com.ffcs.biyiict.config;
    
    import java.sql.*;
    import java.time.ZoneId;
    import java.time.ZonedDateTime;
    import java.time.format.DateTimeFormatter;
    
    import org.apache.ibatis.type.BaseTypeHandler;
    import org.apache.ibatis.type.JdbcType;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    
    
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.core.convert.converter.Converter;
    /**
     * String转ZonedDateTime,解决时间条件查询格式转换问题
     * @author lym
     *
     */
    @Configuration
    public class ZonedDateTimeConverter extends BaseTypeHandler<ZonedDateTime> {
    
    	private static final Logger log = LoggerFactory.getLogger(ZonedDateTimeConverter.class);
    
    	@Bean
        public Converter<String, ZonedDateTime> zonedDateTimeConvert() {
            return new Converter<String, ZonedDateTime>() {
                @Override
                public ZonedDateTime convert(String source) {
                	/*根据需要修改时间格式与时区*/
                    DateTimeFormatter df = DateTimeFormatter
                            .ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault());
                    ZonedDateTime date = null;
                    try {
                    	date = ZonedDateTime.parse(source, df).withZoneSameInstant(ZoneId.of("UTC"));
                    } catch (Exception e) {
                    	log.error("can not convert ZonedDateTime to Date",e.getMessage());
                    }
                    return date;
                }
            };
        }
    
        @Override
        public void setNonNullParameter(PreparedStatement ps, int i, ZonedDateTime parameter, JdbcType jdbcType) throws SQLException {
            // 将 ZonedDateTime 转换为适当的数据库类型并设置参数
            ps.setObject(i, parameter.toLocalDateTime());
        }
    
        @Override
        public ZonedDateTime getNullableResult(ResultSet rs, String columnName) throws SQLException {
            // 从结果集中获取适当的数据库类型并转换为 ZonedDateTime
            Timestamp value = rs.getTimestamp(columnName);
            return value != null ? value.toLocalDateTime().atZone(ZoneId.systemDefault()) : null;
        }
    
        @Override
        public ZonedDateTime getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
            Timestamp value = rs.getTimestamp(columnIndex);
            return value != null ? value.toLocalDateTime().atZone(ZoneId.systemDefault()) : null;
        }
    
        @Override
        public ZonedDateTime getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
            Timestamp value = cs.getTimestamp(columnIndex);
            return value != null ? value.toLocalDateTime().atZone(ZoneId.systemDefault()) : null;
        }
    }
  4. 遇到的坑3:报错:Caused by:com.mysq1.cj . jdbc.exceptions ,Mysq1DataTruncation: Data truncation: Incorrect datetime value:'ox. xDNxz0lxl5sr ox1.xlIjava. tiom ...erlx2E5] oxe4 xEBA ×xl5 1YxBE2 xlNC x1.xoxpwkxl xlb6 xOlx0xO7xEElx09.xO1x7x03-0fFxlO \x' for colu...

    ps:若是应用用到的库是 mysql 的,需要更改驱动的版本才用正常运行,原先的版本是8.0.22,改成8.0.30

    java 复制代码
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.30</version>
    </dependency>
  5. 遇到的坑4:由于是多模块的,我的system模块重写了jar代码,主模块引入了system模块。发现,以jar的方式引入system模块,会导致重写的类失效

    1)修改system的pom,改成war打包方式,避免重写类无效

    java 复制代码
    <packaging>war</packaging>

    2)非server模块的其他模块,有引用system模块的,统一加上provided,这样子打包的时候就不会打包system模块

    java 复制代码
    <dependency>
         <groupId>com.xx.xx</groupId>
         <artifactId>system</artifactId>
         <version>1.0.0</version>
         <scope>provided</scope>
    </dependency>

    3)修改主模块引入system的方式

    java 复制代码
    <dependency>
           <groupId>com.xx.xx</groupId>
           <artifactId>system</artifactId>
           <version>1.0.0</version>
           <type>war</type>
           <exclusions>
               <exclusion>
                   <groupId>*</groupId>
               <artifactId>*</artifactId>
               </exclusion>
          </exclusions>
    </dependency>
        
    <!-- 添加 -->
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
            <overlays>
                <overlay>
                     <groupId>com.xx.xx</groupId>
                     <artifactId>system</artifactId>
                </overlay>
            </overlays>
        </configuration>
    </plugin>

    4)打包的时候,system模块需要先install打一个jar包在target,再install打一个war包到target下,否则有可能报错类找不到

    5)然后全局package即可

    6)如果还是不行,可能是idea缓存问题,删除.dea文件,重新加载项目

  6. 遇到的坑5:项目里面的非pom管理的jar包,无法读取,需要在主模块的pom加上以下这串

    java 复制代码
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
            <execution>
                <id>copy-dependencies</id>
                <phase>compile</phase>
                <goals>
                    <goal>copy-dependencies</goal>
                </goals>
                <configuration>
                    <includeScope>system</includeScope>
                    <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/lib</outputDirectory>
                </configuration>
            </execution>
        </executions>
    </plugin>
  7. 遇到的坑6:存在一些写法,比如public static String xxx= env.getProperty("xxx");这种写法可能在java -jar启动的时候正常,但是放在东方通导致null。

    因为放入东方通后,spring的加载顺序发生了一些变化。导致env可能获取不到,所以触发了异常。这种情况有两种解决办法

    1)使用@value+static静态化加载yml环境变量参数

    2)配置参数直接使用final修饰,这样子在编译的时候,就可以初始化yml环境变量参数

  8. 报错Request header is too large

    原因:springboot项目里面可能已经设置了max-http-header-size,并且没有报错,但是部署到东方通却报错了。这是因为我们springboot设置的这个参数是针对于springboot内置tomcat的,部署到东方通后将不再使用内置的tomcat,所以无效。

    正确的做法是在东方通界面上的"虚拟主机管理"和"HTTP通道管理"都配置以下两个参数即可

    java 复制代码
    maxPostSize			-1
    maxHttpHeaderSize	102400

四、vue前端打包(TongWeb部署)

ps:这种打包方式是针对于TongWeb部署的,如果是nginx或者TongHttpServer部署,跟普通服务器部署方式一样,打个dist包上传解压即可!

  1. npm run build 得到 dist

  2. dist 文件夹里面,添加文件夹和文件

    1)创建文件夹:WEB-INBF

    2)进入WEB-INBF创建文件rewrite.config

    java 复制代码
    RewriteRule ^/index\.html$ - [L]
    RewriteCond %{REQUEST_PATH} !-f
    RewriteRule (.*) /index.html [L]
  3. 进入 dist,打开 cmd,运行 jar -cvf dist.war * 得到 dist.war

  4. 前端一般不会遇到什么bug,直接将dist.war部署上去即可

五、TongWeb部署(前后端一样)

  1. 参数设置

    ps:这里的参数是部署到当前东方通的所有项目共用,可酌情修改,也可以不动

  2. 创建主机

    ps:建议一个应用一个主机,便于区分,参数酌情填写即可

  3. 创建HTTP通道管理

    然后一直下一步,参数自己看着修改,直到最后一步

    创建完毕后,需要再重新修改

    根据自己项目实际情况进行勾选,然后保存即可!

  4. 设置服务器文件路径

    ps:主要是为了部署项目的时候,文件可以直接从服务器指定路径进行勾选

  5. 部署项目

    1)上传文件,选择服务器的话就默认从上一步选择的路径里面,选择底下的文件)

    2)设置前缀

    3)选择主机

    4)完成

  6. 部署结束后,直接使用刚刚设置的端口进行测试访问即可!!!

相关推荐
嘉伟桑3 小时前
Python调用电价API返回JSON示例:分时电价、现货电价和字段解析
后端
武子康3 小时前
Shippy:确定性工具、会话级 Sandbox 与 Live-Data Eval(4 类收敛 + 7 步实现方案 + 6 类评测指标)
前端·人工智能·后端
我叫黑大帅3 小时前
我为什么单一消费者的场景下,要用 Redis List 当消息队列?
redis·后端·面试
Bad_Shepherd3 小时前
vue-element-plus-admin添加自定义svg图标,并且图标选择组件可选自定义图标
vue.js·elementui·前端框架
AskHarries4 小时前
文件上传系统
后端
止语Lab4 小时前
好的 DX 不等于少写代码——三种语言的摩擦力设计课
后端
吃饱了得干活4 小时前
别再手动解析 LLM 输出了!LangChain 四种结构化输出方案对比
后端·python·langchain
程序员天天困4 小时前
Arthas trace 命令怎么用?一行定位最慢那行代码
jvm·后端
Huiturn4 小时前
GPT 5.6 连续编码 10 小时,纯 Python 啃下 Word 二进制格式——doc2docx 实现拆解
后端
dkbnull5 小时前
Spring Boot请求处理组件对比详解
java·spring boot