maven更换mirror

maven工程,莫名其妙的错误。报错提示找不到类,但是,对应的jar包是存在的,于是到
http://search.maven.org/ 手动下载此jar,发现大小不一致:手工下载的org.eclipse.jdt.core-3.13.102.jar,只有6M多一点,但是maven下载的却有12M。

# username @ usernames-MacBook-Pro in ~/.m2/repository/org/eclipse/jdt/org.eclipse.jdt.core/3.13.102 [9:52:55] 
$ ls -alhtr
total 26664
drwxr-xr-x  3 username  staff    96B May  9 20:27 ..
-rw-r--r--  1 username  staff   2.6K May  9 20:27 org.eclipse.jdt.core-3.13.102.pom
-rw-r--r--  1 username  staff    40B May  9 20:27 org.eclipse.jdt.core-3.13.102.pom.sha1
-rw-r--r--  1 username  staff    40B May  9 20:33 aether-409eb570-abe9-44d0-be50-877a99f090fb-org.eclipse.jdt.core-3.13.102.jar.sha1-in-progress
-rw-r--r--  1 username  staff    12M May  9 20:34 org.eclipse.jdt.core-3.13.102.jar
-rw-r--r--  1 username  staff   219B May  9 20:36 _remote.repositories
drwxr-xr-x  7 username  staff   224B May  9 20:36 .

删除3.13.102这个目录,然后在maven工程中,update projects,即可。

另外,还有遇到过

Archive for required library: 
‘********.jar’ 
in project ‘xxx’ cannot be read or is not a valid ZIP file 

同样的,删除jar包所在的目录,然后在maven工程上,右键,update projects即可。

遇到过几次这种类似问题,怀疑是因为网络不好的原因导致的,于是更换了maven的镜像。
在maven的安装目录下,conf文件夹下的settings.xml文件,在标签下加入下面内容即可。

<!-- 阿里云仓库 --> 
<mirror>
    <id>alimaven</id>
    <mirrorOf>central</mirrorOf>
    <name>aliyun maven</name>
    <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>

<!-- 中央仓库1 --> 
<mirror>
    <id>repo1</id>
    <mirrorOf>central</mirrorOf>
    <name>Human Readable Name for this Mirror.</name>
    <url>http://repo1.maven.org/maven2/</url>
</mirror>

<!-- 中央仓库2 --> 
<mirror>
    <id>repo2</id>
    <mirrorOf>central</mirrorOf>
    <name>Human Readable Name for this Mirror.</name>
    <url>http://repo2.maven.org/maven2/</url>
</mirror>

参考文章
1.https://www.cnblogs.com/xiongxx/p/6057558.html

猜你喜欢

转载自blog.csdn.net/yangyangrenren/article/details/80265385