maven引入外部jar包的几种方式

1. 通过dependency引入

在项目根路径新建lib文件夹,把jar包扔进去
在这里插入图片描述
配置pom.xml

        <!-- 导入敏感词匹配包 -->
        <dependency>
            <groupId>com.hctrl</groupId>
            <artifactId>word-spring-boot-start</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <scope>system</scope> <!--system,类似provided,需要显式提供依赖的jar以后,Maven就不会在Repository中查找它-->
            <systemPath>${project.basedir}/lib/word-spring-boot-start-0.0.1-SNAPSHOT.jar</systemPath>
        </dependency>

光是上面的配置,打包是进不去的。在spring-boot-maven-plugin 添加true

 <build>
  <plugins>
     <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
         <configuration>
             <includeSystemScope>true</includeSystemScope>
         </configuration>
        <executions>
            <execution>
                <phase>none</phase>
            </execution>
        </executions>
      </plugin>
   </plugins>
 </build>

2. 将外部jar打入本地maven仓库

mvn install:install-file
 -Dfile=D:\software\maven_repo\org\postgresql\hgjdbc\6.0.3-SNAPSHOT\hgjdbc-6.2.0.jar
 -DgroupId=org.postgresql
 -DartifactId=hgjdbc
 -Dversion=6.0.3-SNAPSHOT
 -Dpackaging=jar

对应的maven配置

<dependency>
   <groupId>org.postgresql</groupId>
   <artifactId>hgjdbc</artifactId>
   <version>6.0.3-SNAPSHOT</version>
</dependency>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值