如何让eclipse正确引用已存在的maven jar包?
- 内容介绍
- 文章标签
- 相关推荐
本文共计386个文字,预计阅读时间需要2分钟。
之前,使用Maven管理项目的童鞋都知道,本地会有一个`~/.m2/repository`仓库,这是用来存放jar包的地方。但是,在Eclipse中的Maven仓库中,却找不到本地仓库中的jar包。原因在于Maven中的本地仓库配置。
之前,用过maven管理项目的童鞋都知道本地会有一个${User_Home}.m2/repository仓库 是用来存放jar包的地方。但是,在eclipse中的maven仓库中 搜索不到本地仓库中的jar包。
原因是因为maven中的本地仓库的index索引没有更新,导致在eclipse的maven插件中搜索不到。
解决方案:
在eclipse中打开菜单 window-> show view –> other –> Maven -> maven repositories
打开之后,选择local repositories –> local repository ,右击,选择Build index.
新完索引之后,在通过右键单击pom.xml文件选择maven –> add dependency 或者是打开pom.xml文件,选择dependencies –>add 时,就可以搜索到本地仓库的jar包了。
补充知识:spring中出现的错误:The import org.springframework cannot be resolved
用myeclipse+maven环境,做spring+mybatis测试的时候遇到的。
本文共计386个文字,预计阅读时间需要2分钟。
之前,使用Maven管理项目的童鞋都知道,本地会有一个`~/.m2/repository`仓库,这是用来存放jar包的地方。但是,在Eclipse中的Maven仓库中,却找不到本地仓库中的jar包。原因在于Maven中的本地仓库配置。
之前,用过maven管理项目的童鞋都知道本地会有一个${User_Home}.m2/repository仓库 是用来存放jar包的地方。但是,在eclipse中的maven仓库中 搜索不到本地仓库中的jar包。
原因是因为maven中的本地仓库的index索引没有更新,导致在eclipse的maven插件中搜索不到。
解决方案:
在eclipse中打开菜单 window-> show view –> other –> Maven -> maven repositories
打开之后,选择local repositories –> local repository ,右击,选择Build index.
新完索引之后,在通过右键单击pom.xml文件选择maven –> add dependency 或者是打开pom.xml文件,选择dependencies –>add 时,就可以搜索到本地仓库的jar包了。
补充知识:spring中出现的错误:The import org.springframework cannot be resolved
用myeclipse+maven环境,做spring+mybatis测试的时候遇到的。

