zoukankan      html  css  js  c++  java
  • spring boot打包为war包,引入外部jar包

    1,在src/main/resource下新建目录jar,将外部jar包放在该目录下

     2,在pom.xml中添加依赖

     groupId,artifactId,version可随便写

    <dependency>
                <groupId>com.huawei</groupId>
                <artifactId>gsjdbc4</artifactId>
                <version>1.0</version>
                <scope>system</scope>
                <systemPath>${basedir}/src/main/resources/jar/gsjdbc4.jar</systemPath>
            </dependency>
            <dependency>
                <groupId>com.huawei</groupId>
                <artifactId>gsjdbc200</artifactId>
                <version>1.0</version>
                <scope>system</scope>
                <systemPath>${basedir}/src/main/resources/jar/gsjdbc200.jar</systemPath>
            </dependency>

    此时,本地启动项目访问是没有问题的,但是打包的话就会报错,需要以下步骤

    3,pom.xml中增加plugin配置

    <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <configuration>
                        <webResources>
                            <resource>
                                <directory>src/main/resources/jar/</directory>
                                <targetPath>WEB-INF/lib/</targetPath>
                                <includes>
                                    <include>**/*.jar</include>
                                </includes>
                            </resource>
                        </webResources>
                    </configuration>
                </plugin>

    然后再打包即可

    4,遇到的问题

    打包时报错: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)

    原因: maven 插件 maven-war-plugin 中 Servlet 版本太低,要求必须要有web.xml文件才行

    解决方法: 把plugin配置里面的<version>2.4</version>去掉,再次打包即可

  • 相关阅读:
    hive order、sort、distribute、cluster by区别与联系
    hive over窗口函数的使用
    hive中row_number() rank() dense_rank()的用法
    hive中文乱码问题
    hive分桶表的学习
    hive的调优经验
    Hive的学习
    hive grouping sets和GROUPING__ID的用法
    hive修复分区或修复表 以及msck命令的使用
    Vue中使用websocket
  • 原文地址:https://www.cnblogs.com/cailijuan/p/11934444.html
Copyright © 2011-2022 走看看