天天看點

SpringBoot項目中引入第三方jar包,本地運作成功,打包部署運作失敗問題

問題描述:

  SpringBoot項目中引入第三方jar包,本地運作成功,打包部署運作失敗問題

原因:

  SpringBoot項目中引入第三方jar包,當項目打包部署的時候, < scope>system< /scope>類型的依賴不會自動打包進去,需要對pom.xml檔案進行處理,這樣第三方的jar包才能打包進去。

項目案例分析:

  項目結構:

SpringBoot項目中引入第三方jar包,本地運作成功,打包部署運作失敗問題
  pom.xml

<!--釘釘工具包-->
 <dependencies>
        <dependency>
            <groupId>com.taobao.top</groupId>
            <artifactId>top-api-sdk-java</artifactId>
            <version>1.0</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/src/main/resources/lib/taobao-sdk-java-auto_1479188381469-20210113.jar</systemPath>
        </dependency>
    </dependencies>
           

  解決方法:在< build>标簽中添加

<configuration>
      <includeSystemScope>true</includeSystemScope>
</configuration>
           
<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <includeSystemScope>true</includeSystemScope>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
           

總結: