• 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>
    
  • 相关阅读:
    关于有序查找的随笔
    Spring框架(一) 创建bean
    Linux常用命令
    Spring框架(二) bean的歧义性
    java实现图片文字识别的两种方法
    分享基于分布式Http长连接框架代码模型
    分享基于分布式Http长连接框架设计模型
    无限树Jquery插件zTree的使用方法
    分享基于分布式Http长连接框架
    使用vs编译事件来动态发布配置文件
  • 原文地址:https://www.cnblogs.com/masterchd/p/16179635.html
Copyright © 2020-2023  润新知