一.最初引入方法
1.ideal引入jar包
ideal -> file-> project Structure? -> Modules -> Dependencies -> JARS or directories? 方式引入項(xiàng)目

2.運(yùn)行項(xiàng)目
開(kāi)心,項(xiàng)目可以正常跑起來(lái)

3.?打包

奇怪的事情發(fā)生了
剛剛引入的包,找不到,報(bào)?java.lang.NoClassDefFoundError

二.解決方法:
1.按上面的方法將引入的jar包刪除
2.在項(xiàng)目下,創(chuàng)建lib目錄,將jar包c(diǎn)opy過(guò)來(lái),重命名為格式:xxx.xxx.xxx-1.3.7.jar? (一定要注意命名方式,會(huì)報(bào)錯(cuò))

3.在項(xiàng)目pom.xml方法增加依賴(lài)包
<dependency>
? ? ? ? ? ? <groupId>com.mytest</groupId>
? ? ? ? ? ? <artifactId>unifiedverification</artifactId>
? ? ? ? ? ? <version>1.3.7</version>
? ? ? ? ? ? <scope>system</scope>
? ? ? ? ? ? <systemPath>${project.basedir}/src/main/lib/com.mytest.unifiedverification-1.3.7.jar</systemPath>
? ? ? ? </dependency>
<systemPath>是引入jar包在項(xiàng)目的路徑
4.重新運(yùn)行,與打包項(xiàng)目? ? 終于正常了,打包完成,在項(xiàng)目target目錄下有打包出來(lái)的jar文件

5.運(yùn)行jar包?java -jar tools-0.0.1-SNAPSHOT.jar
報(bào)了跟上面一樣的錯(cuò)誤,找不到引入jar包的方法

只要是由于maven的 <scope></scope>引起的:scope的配置項(xiàng)可參考https://blog.csdn.net/lz619719265/article/details/82352562
6.解決方法
構(gòu)建增加配置項(xiàng)
? ? ? ? ? ? ? ? <configuration>
? ? ? ? ? ? ? ? ? ? <includeSystemScope>true</includeSystemScope>
? ? ? ? ? ? ? ? </configuration>
pom文件構(gòu)建完整build如下
<build>
? ? ? ? <plugins>
? ? ? ? ? ? <plugin>
? ? ? ? ? ? ? ? <groupId>org.springframework.boot</groupId>
? ? ? ? ? ? ? ? <artifactId>spring-boot-maven-plugin</artifactId>
? ? ? ? ? ? ? ? <configuration>
? ? ? ? ? ? ? ? ? ? <includeSystemScope>true</includeSystemScope>
? ? ? ? ? ? ? ? </configuration>
? ? ? ? ? ? </plugin>
? ? ? ? </plugins>
? ? </build>
7.重新打包,再運(yùn)行jar?包,現(xiàn)在可以正常起服務(wù)了,