解决eclipse中maven引用不到已经存在maven中jar包的问题
之前,用过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文件中添加依赖,代码如下:

上一篇:SpringBoot2 集成log4j2日志框架的实现
栏 目:JAVA代码
本文标题:解决eclipse中maven引用不到已经存在maven中jar包的问题
本文地址:http://www.codeinn.net/misctech/95780.html


阅读排行
- 1Java Swing组件BoxLayout布局用法示例
- 2java中-jar 与nohup的对比
- 3Java邮件发送程序(可以同时发给多个地址、可以带附件)
- 4Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.Type异常
- 5Java中自定义异常详解及实例代码
- 6深入理解Java中的克隆
- 7java读取excel文件的两种方法
- 8解析SpringSecurity+JWT认证流程实现
- 9spring boot里增加表单验证hibernate-validator并在freemarker模板里显示错误信息(推荐)
- 10深入解析java虚拟机




