您的位置:首页 > 其它

导入maven项目遇到的问题

2016-03-19 10:59 351 查看
在使用maven管理项目的出现的初级问题:1.我把大牛配置好的maven项目导入到myeclipse,我修改了settings.xml文件,改成我本地的默认仓库。发现找不到ojdbc.jar,报错:maven中引入oracle驱动报错Missing artifact com.oracle:ojdbc7:jar:12.1.0.2。在网上找到解决方案,原来是因为oracle的ojdbc.jar是收费的,所以maven的中央仓库中没有这个资源,只能通过配置本地库才能加载到项目中去。解决方案,去oracle官网下载ojdbc驱动,再安装到本地仓库。将下载好的ojdbc7.jar复制到系统默认的用户目录下,我的用户目录是C:\Users\Administrator,然后在该目录下打开命令窗口,然后输入如下命令:mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0.2 -Dpackaging=jar -Dfile=ojdbc7.jar .已经成功安装了,并且名字都被改了。这个时候,再去项目的pom.xml中引入,就会发现一切都正常了。2.上面问题解决了,又有了新的问题。maven项目出现如下错误,求指点;CoreException: Could not calculate build plan:
CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2: ArtifactResolutionException: Failure to transfer org.apache.maven.plugins:maven-compiler-plugin:pom:2.3.2 from http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.plugins:maven-compiler-plugin:pom:2.3.2 from/to central (http://repo1.maven.org/maven2): null to http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/2.3.2/maven-compiler-plugin-2.3.2.pom
网上搜索到答案:
http://repo1.maven.org/maven2这个中央仓库地址已经被屏蔽了,不能访问,所以maven用到的插件和jar下载失败,且你的电脑上的本地仓库.m2并没有下载好maven的插件等,项目自然不能正常执行maven命令。解决方法,1.如果没有私服(例如nexus),那么就把‘另外电脑中‘的本地仓库.m2目录拷贝到你的电脑上,并在maven conf settings.xml里面设置<localRepository>为.m2目录。2.有私服,就在settings.xml里面配置nexus地址,从它上面下载。

我看了一下settings.xml文件,发现真的有nexus。
原来所有的jar包不用下载到本地。大牛已经放到了nexus上面(包过上面的ojdbc7.jar),我们只需要从nexus下载即可。

3.项目右键,mvn install报错:-Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME
解决方式:
在default vm arguments中填写:-Dmaven.multiModuleProjectDirectory
即可。

Maven常用仓库地址:

http://mvnrepository.com/ http://search.maven.org/

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: