• SpringBoot 引入第三方 jar


    SpringBoot 引入第三方 jar

    项目结构

    -BCJS
    	|--lib
    		|--hsm-talos-1.0.1.jar
    	|--src
    	|--pom.xml
    

    step1 : 配置第三方 jar 为依赖库

    1. 右键选中第三方 jar
    2. 添加为库 (Add as Library)

    step2 : 依赖中引入第三方 jar

    	<dependency>
                <groupId>cn.org.bjca.hms.client</groupId>
                <artifactId>hsm-talos-1.0.1</artifactId>
                <version>1.0.1</version>
                <type>jar</type>
                <scope>system</scope>
                <systemPath>${project.basedir}/lib/hsm-talos-1.0.1.jar</systemPath>
            </dependency>
    

    step3 :修改打包配置包括本地 jar

    	<build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <configuration>
                        <includeSystemScope>true</includeSystemScope>
                        <excludes>
                            <exclude>
                                <groupId>org.projectlombok</groupId>
                                <artifactId>lombok</artifactId>
                            </exclude>
                        </excludes>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    

    step4 : 使用 mvn package 进行打包

    附录

    pom.xml

    <?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.5.4</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
        <groupId>com.safe</groupId>
        <artifactId>BCJS</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <name>BCJS</name>
        <description>BCJS</description>
        <properties>
            <java.version>1.8</java.version>
        </properties>
        <dependencies>
            <!-- Sa-Token 权限认证, 在线文档:http://sa-token.dev33.cn/ -->
            <dependency>
                <groupId>cn.dev33</groupId>
                <artifactId>sa-token-spring-boot-starter</artifactId>
                <version>1.27.0</version>
            </dependency>
            <!-- 工具类安装HuTool 在线文档:https://www.hutool.cn/docs/#/ -->
            <dependency>
                <groupId>cn.hutool</groupId>
                <artifactId>hutool-all</artifactId>
                <version>5.7.13</version>
            </dependency>
            <!-- Mysql JDBC支持 -->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
            </dependency>
            <!-- Spring-data-jpa依赖 -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-data-jpa</artifactId>
            </dependency>
            <!--JDBC依赖-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-jdbc</artifactId>
            </dependency>
            <!--接口文档依赖-->
            <dependency>
                <groupId>com.github.xiaoymin</groupId>
                <artifactId>knife4j-spring-boot-starter</artifactId>
                <version>3.0.3</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>fastjson</artifactId>
                <version>1.2.78</version>
            </dependency>
            <!--SpringBoot基础组件-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <optional>true</optional>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>cn.org.bjca.hms.client</groupId>
                <artifactId>hsm-talos-1.0.1</artifactId>
                <version>1.0.1</version>
                <type>jar</type>
                <scope>system</scope>
                <systemPath>${project.basedir}/lib/hsm-talos-1.0.1.jar</systemPath>
            </dependency>
    
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <configuration>
                        <includeSystemScope>true</includeSystemScope>
                        <excludes>
                            <exclude>
                                <groupId>org.projectlombok</groupId>
                                <artifactId>lombok</artifactId>
                            </exclude>
                        </excludes>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    
    </project>
    
  • 相关阅读:
    【Unity】近期整理Unity4.x 项目升级Unity5.0 过程中出现的各种常见问题,与大家共享。
    extjs Combox 调用数据
    CSDN博客2014年4月24日清理缓存
    在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法訪问server。请验证实例名称是否正确而且 SQL Server 已配置为同意远程连接。
    海思 3520D 移植Qt4.5.3 一
    Android 输入框限制字符输入数
    Making User-Managed Backups-17.4、Making User-Managed Backups of Online Tablespaces and Datafiles
    spring 使用外部属性文件
    mysql字符串替换
    maven3+eclipse搭建webAPP企业级实战《一》
  • 原文地址:https://www.cnblogs.com/masterchd/p/16179635.html
Copyright © 2020-2023  润新知