Spring boot introduces external jar s and packages the project through maven, unable to start

Keywords: SDK Maven log4j snapshot

Road to crater

Preface

First of all, you must print the error log in your project (I use log4j), so that you can see what causes the startup error.

Introducing jar

How to import local jar package
1. Create a new lib folder under resources and put the jar package file in this directory

2. In the pom file definition, the dependency points to the jar

<dependency>
            <groupId>com.aliyun.alicom</groupId>
            <artifactId>alicom-mns-receive-sdk</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/src/main/resources/lib/alicom-mns-receive-sdk-1.0.0.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>com.aliyun.mns</groupId>
            <artifactId>aliyun-sdk-mns</artifactId>
            <version>1.1.8</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/src/main/resources/lib/aliyun-sdk-mns-1.1.8.jar</systemPath>
        </dependency>
</dependency>

Note: the point is that the path of systemPath must be the path of your jar. Others can be filled in according to the routine. The requirements are not too strict. ${project.basedir} is just a constant of the system itself, regardless of it
If you need to make a jar, at the same time, introduce the jar into it
Just introduce parameters to the packaging plug-in of springboot in the pom of maven

<includeSystemScope>true</includeSystemScope>

It is shown in the pom file

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

Posted by pumaf1 on Thu, 21 Nov 2019 11:14:30 -0800