SoFunction
Updated on 2025-03-01

About maven pom file configuration loading jar package under lib

maven pom file configuration loading jar package under lib

The project needs to reference a jar placed in lib by a third party

So configuration is required, but it is best to put it in the company's own maven private server

<dependency>
    <groupId></groupId>
    <artifactId>wsdl4j</artifactId>
    <version>1.5.1</version>
    <scope>system</scope>
    <systemPath>${basedir}/lib/</systemPath>
</dependency>

This kind of external dependency jar sometimes has problems with deployment, so you can use maven jar plugins.

Reference official website:/plugins/maven-jar-plugin/

Springboot project can be configured

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId></groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>${}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<build>
    <plugins>
        <plugin>
            <groupId></groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <plugin>
            <groupId></groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.0.</version>
            <configuration>
                <mainClass></mainClass>
            </configuration>
            <executions>
                <execution>
                    <id>repackage</id>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

appendix

Maven's dependency scope:

  • compile: Maven's default dependency range, this type of dependency is valid during compilation, running, and testing.
  • provided: Effective during compilation and testing, but not during runtime
  • runtime: Valid when running and testing, but not when compiling the code
  • test: Only valid during testing, including the compilation and execution of test code
  • system: Effective during compilation and testing, but not during runtime

Summarize

The above is personal experience. I hope you can give you a reference and I hope you can support me more.