Maven 导入本地Jar包

导入Jar包

maven项目根目录下新建名为lib的文件夹,将准备好的外部jar包移到该目录下。

配置Jar包依赖

使用pom.xml文件scopesystem属性来引入jar包:

0
1
2
3
4
5
6
<dependency>
    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/lib/demo.jar</systemPath>
</dependency>

在这种方式下,如果需要打包发布,还需要额外配置:

 0
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <includeSystemScope>true</includeSystemScope>
            </configuration>
        </plugin>
    </plugins>
</build>
Licensed under CC BY-NC-SA 4.0
最后更新于 Apr 02 2024 17:26 CST
赞助
Sponsor WeChat Pay
Sponsor Ali Pay
Powered by HugoStack