zoukankan      html  css  js  c++  java
  • SpringBoot打包第三方jar包

    springboot利用maven中引入项目依赖的jar包,主要通过在pom.xml中使用坐标添加依赖的方式。 但如果需要引用的jar包在Maven中央仓库下没有(例如达梦)就需要手动引入jar文件

    首先在工程目录下新建libs目录,将下载的jar包放入

    然后打开pom.xml添加jar包

    <dependency>
                <groupid>com.serotonin</groupid>
                <artifactid>dm-jar</artifactid>
                <scope>system</scope>
                <systempath>${pom.basedir}/libs/dmJdbcDriver.jar</systempath>
                <version>1.1</version>
                <type>jar</type>
                <optional>true</optional>
            </dependency>
    

    scope要写system,然后systemPath就是上面jar包的路径

    最后配置pom.xml的build段

    <!--?xml version="1.0" encoding="UTF-8"?-->
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <parent>
            <artifactid>xxx_gov</artifactid>
            <groupid>org.example</groupid>
            <version>1.0-SNAPSHOT</version>
        </parent>
        <modelversion>4.0.0</modelversion>
    
        <artifactid>xxx_sakura_card</artifactid>
    
        <properties>
            <maven.compiler.source>8</maven.compiler.source>
            <maven.compiler.target>8</maven.compiler.target>
        </properties>
        <dependencies>
            <dependency>
                <groupid>org.example</groupid>
                <artifactid>xxx_common</artifactid>
                <version>1.0-SNAPSHOT</version>
            </dependency>
    
            <dependency>
                <groupid>com.serotonin</groupid>
                <artifactid>dm-jar</artifactid>
                <scope>system</scope>
                <systempath>${pom.basedir}/libs/dmJdbcDriver.jar</systempath>
                <version>1.1</version>
                <type>jar</type>
                <optional>true</optional>
            </dependency>
    
            <dependency>
                <groupid>org.mybatis</groupid>
                <artifactid>mybatis</artifactid>
            </dependency>
    
            <dependency>
                <groupid>org.springframework.boot</groupid>
                <artifactid>spring-boot-starter-web</artifactid>
            </dependency>
    
            <dependency>
                <groupid>tk.mybatis</groupid>
                <artifactid>mapper-spring-boot-starter</artifactid>
                <version>${mapper-spring-boot-starter.version}</version>
            </dependency>
    
    
            <dependency>
                <groupid>io.springfox</groupid>
                <artifactid>springfox-swagger2</artifactid>
            </dependency>
            <dependency>
                <groupid>io.springfox</groupid>
                <artifactid>springfox-swagger-ui</artifactid>
            </dependency>
            <dependency>
                <groupid>com.github.xiaoymin</groupid>
                <artifactid>swagger-bootstrap-ui</artifactid>
            </dependency>
    
            <dependency>
                <groupid>javax.persistence</groupid>
                <artifactid>persistence-api</artifactid>
            </dependency>
            <dependency>
                <groupid>io.jsonwebtoken</groupid>
                <artifactid>jjwt</artifactid>
            </dependency>
    
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <groupid>org.springframework.boot</groupid>
                    <artifactid>spring-boot-maven-plugin</artifactid>
                    <configuration>
                        <!-- 指定该Main Class为全局的唯一入口 -->
                        <mainclass>com.sakuraCard.SakuraCardApplication</mainclass>
                        <layout>ZIP</layout>
                        <includesystemscope>true</includesystemscope>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>repackage</goal><!--可以把依赖的包都打包到生成的Jar包中-->
                            </goals>
                        </execution>
                    </executions>
                </plugin>
    
            </plugins> 
        </build>
    
    </project>
    

    最后大功告成

  • 相关阅读:
    Python之爬虫(十四) Scrapy框架的架构和原理
    Python之爬虫从入门到放弃(十三) Scrapy框架整体的了解
    Python之 爬虫(十二)关于深度优先和广度优先
    kali linux
    html5笔记
    python 3.4.3 安装pygame
    跳格子
    简单字符串查找
    KMP算法查找字符串
    ios系统保存校园网密码
  • 原文地址:https://www.cnblogs.com/linkanyway/p/maven-thrid-party-jar-pacakage.html
Copyright © 2011-2022 走看看