Maven引用本地lib文件夹内jar包

😂 这篇文章最后更新于994天前,您需要注意相关的内容是否还可用。

在一个项目中使用了maven,也使用了本地jar包,若这jar包不能通过一般maven进行使用,因为在公共的maven库中没此包下载不了导致打包失败。

可以通过添加相关配置解决,例如引用iceblue的包,直接引用会显示无法下载。只需:

        <dependency>
            <groupId> e-iceblue </groupId>
            <artifactId>spire.pdf</artifactId>
            <version>3.11.6</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/spire.pdf-3.11.6.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>e-iceblue</groupId>
            <artifactId>spire.pdf.free</artifactId>
            <version>3.9.0</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/spire.pdf.free-3.9.0.jar</systemPath>
        </dependency>

并且在插件中配置(以下是以springboot项目为例)

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.3.7.RELEASE</version>
                <configuration>
                    <mainClass>com.example.demo.ProjectSeedMasterApplication</mainClass>
                    <includeSystemScope>true</includeSystemScope>
                </configuration>
                <executions>
                    <execution>
                        <id>repackage</id>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>