当前位置:主页 > 软件编程 > JAVA代码 >

解决eclipse中maven引用不到已经存在maven中jar包的问题

时间:2021-04-06 10:02:52 | 栏目:JAVA代码 | 点击:

之前,用过maven管理项目的童鞋都知道本地会有一个${User_Home}.m2/repository仓库 是用来存放jar包的地方。但是,在eclipse中的maven仓库中 搜索不到本地仓库中的jar包。

原因是因为maven中的本地仓库的index索引没有更新,导致在eclipse的maven插件中搜索不到。

解决方案:

在eclipse中打开菜单 window-> show view ?C> other ?C> Maven -> maven repositories

打开之后,选择local repositories ?C> local repository ,右击,选择Build index.

新完索引之后,在通过右键单击pom.xml文件选择maven ?C> add dependency 或者是打开pom.xml文件,选择dependencies ?C>add 时,就可以搜索到本地仓库的jar包了。

补充知识:spring中出现的错误:The import org.springframework cannot be resolved

用myeclipse+maven环境,做spring+mybatis测试的时候遇到的。

错误:The import org.springframework cannot be resolved

关于这个错误,从字面意思上看属于有的包没有导入。于是在网上查找需要导入哪个包,说什么的都有,但是找到了个靠谱的 参考,下面是感觉重要的摘了下来:

注意:SpringJUnit4ClassRunner这个类是位于spring-test-4.1.6.RELEASE.jar这个包中的

解决办法是在pom.xml文件中添加依赖,代码如下:

您可能感兴趣的文章:

相关文章