eclipse版本為2018-12(4.10.0)
1、創建一個jar包
首先自己建立了一個maven project,名為jweb。GAV坐標:
<groupId>amberai</groupId> <artifactId>jweb</artifactId> <version>0.0.1-SNAPSHOT</version>
然后,使用maven install將jweb打包加載到本地的maven倉庫
2、使用自己創建的jar包
現在項目jweb-apiweb要引用jweb-0.0.1-SNAPSHOT.jar,在項目jweb-apiweb的pom文件中添加:
<dependencies> <dependency> <groupId>amberai</groupId> <artifactId>jweb</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> </dependencies>
效果如下:
啟動項目jweb-apiweb,報錯:各種NoClassDefFoundError,但是看項目jweb-apiweb的maven依賴明明已經有對應的Class。並且jweb也加載到本地maven倉庫了。不知道為什么還是找不到類。
解決方法:https://blog.csdn.net/qq_30999361/article/details/83863931。盡管這可以解決,但每次測試都把jweb項目close,很不方便。
把jweb項目close后效果: