zoukankan      html  css  js  c++  java
  • 导入maven项目遇到的问题

    在使用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:UsersAdministrator,然后在该目录下打开命令窗口,然后输入如下命令:

     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/





  • 相关阅读:
    内存泄漏检测工具VLD在VS2010中的使用举例
    boost::threadpool 调用类成员变量并传入参数 的方法
    boost之ThreadPool
    DllMain 用法
    分布式锁的几种实现方式
    利用cbmakegen导出Code::blocks的Makefile
    搜集C++实现的线程池
    微软开源rDSN分布式系统开发框架
    腾讯互娱开源分布式开发框架Pebble
    SpringBoot指定额外需要扫描的包
  • 原文地址:https://www.cnblogs.com/xingxing0521/p/5294574.html
Copyright © 2011-2022 走看看