J. Zhang
J. Zhang

Reputation: 157

Add external library .jar to Spring boot .jar /lib without mvn install

I've been reading around on this site and others, trying to figure out how add these external jars without doing mvn install, and haven't had any success. I was reading somewhere that maven-shade could address my problem, but I could never get that to work? I know spring boot doesn't like system scope but it seems to error out if I choose something else?

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.springframework</groupId>
    <artifactId>gs-rest-service</artifactId>
    <version>0.1.0</version>
    <packaging>jar</packaging>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.3.RELEASE</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
       ...
        <dependency>
              <groupId>sample</groupId>  
               <artifactId>com.sample</artifactId>  
               <version>1.0</version> 
              <scope>system</scope>
              <systemPath>${project.basedir}/src/main/resources/lib/enterprise.jar</systemPath>
        </dependency>
        <dependency>
              <groupId>sample1</groupId>  
               <artifactId>com.sample1</artifactId>  
               <version>1.0</version> 
              <scope>system</scope>
              <systemPath>${project.basedir}/src/main/resources/lib/gs.jar</systemPath>
        </dependency>
        <dependency>
              <groupId>sample2</groupId>  
               <artifactId>com.sample2</artifactId>  
               <version>1.0</version> 
              <scope>system</scope>
              <systemPath>${project.basedir}/src/main/resources/lib/Util.jar</systemPath>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-io -->
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-io</artifactId>
    <version>1.3.2</version>
</dependency>



    </dependencies>

    <properties>
        <java.version>1.8</java.version>
        <start-class>ves.sfdc.Application</start-class>
    </properties>


    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>

        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-releases</id>
            <url>https://repo.spring.io/libs-release</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>spring-releases</id>
            <url>https://repo.spring.io/libs-release</url>
        </pluginRepository>
    </pluginRepositories>



</project>

Upvotes: 0

Views: 15377

Answers (1)

Paolo Mastinu
Paolo Mastinu

Reputation: 81

You can create a new directory "lib" on your project, put your jars in this directory and then add them to your classpath.

If your IDE is IntelliJ you can follow this link:

Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA project

If you use another IDE you have to find on google how to add jar on your project classpath.

Upvotes: 1

Related Questions