一.最初引入方法
1.ideal引入jar包
ideal -> file-> project Structure -> Modules -> Dependencies -> JARS or directories 方式引入项目
2.运行项目
开心,项目可以正常跑起来
,3. 打包
奇怪的事情发生了
刚刚引入的包,找不到,报 java.lang.NoClassDefFoundError
二.解决方法:
1.按上面的方法将引入的jar包删除
2.在项目下,创建lib目录,将jar包copy过来,重命名为格式:xxx.xxx.xxx-1.3.7.jar (一定要注意命名方式,会报错)
3.在项目pom.xml方法增加依赖包
<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包在项目的路径
4.重新运行,与打包项目 终于正常了,打包完成,在项目target目录下有打包出来的jar文件
5.运行jar包 java -jar tools-0.0.1-SNAPSHOT.jar
报了跟上面一样的错误,找不到引入jar包的方法
只要是由于maven的 <scope></scope>引起的:scope的配置项可参考https://blog.csdn.net/lz619719265/article/details/82352562
6.解决方法
构建增加配置项
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
pom文件构建完整build如下
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
</build>
7.重新打包,再运行jar 包,现在可以正常起服务了,
网友评论