如果项目中使用了maven来管理依赖,但是同时需要添加本地的jar包(比如说有些jar包在maven的中央仓库中找不到),这时不能直接在项目工程(Ctrl + Shift + Alt + S)的module中添加磁盘上的jar包,否则会报错:java.lang.NoClassDefFoundError。这时可以把本地的jar包用maven install命令添加到maven的本地仓库里再在pom.xml文件中添加dependency即可。
mvn install:install-file -Dfile=C:\Users\Desktop\java读取shp\soft2com-shape-1.1.jar
-DgroupId=com.soft2com -DartifactId=com-soft2com -Dversion=0.0.1 -Dpackaging=jar
<dependency>
<groupId>com.soft2com</groupId>
<artifactId>common-kafka</artifactId>
<version>0.0.1</version>
</dependency>