远程登录主机之后用eclipse创建maven项目时报错

jdk:
export MAVEN_HOME=/data/software/apache-maven-3.3.3
export JAVA_HOME=/usr/java/jdk1.7.0_45-cloudera
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin

在secureCRT中执行mvn -version 出现以下信息:
# maven -version
-bash: maven: command not found
# mvn -version
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T19:57:37+08:00)
Maven home: /data/software/apache-maven-3.3.3
Java version: 1.7.0_45, vendor: Oracle Corporation
Java home: /usr/java/jdk1.7.0_45-cloudera/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-431.23.3.el6.x86_64", arch: "amd64", family: "unix"

也已经把 . /etc/profile写到/etc/xrdp/startwm.sh中:
# cat /etc/xrdp/startwm.sh 
#!/bin/sh
. /etc/profile

在远程中执行mvn出现以下信息:
# mvn
Scanning for projects...
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 0.117 s
Finished at: 2016-03-27T22:42:39+08:00
Final Memory: 4M/28M
------------------------------------------------------------------------
No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format : or ::. Available lifecycle phases are: validate, initialize, generate-sources, rocess-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-est-classes, test, prepare-package, package, pre-integration-test, integration-test, post-ntegration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. ->
 
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
 
For more information about the errors and possible solutions, please read the following articles:
http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException

执行 which mvn 出现以下信息:
# which mvn
/data/software/apache-maven-3.3.3/bin/mvn
 
但在eclipse中创建项目时还是报这样的错,请高手指点
已邀请:

wangxiaolei

赞同来自: Mr_niu fish

由于网络原因,现在你云主机上本地库/root/.m2目录下就少很多文件,导致不能创建maven项目。
建议先把 .m2这个目录删掉,把maven配置上小象的mirror
然后执行下mvn -B archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DgroupId=com.mycompany.app -DartifactId=my-app
然后再新建maven项目试试。

我在你的云主机上留了一个备份/root/m2bak
可以把现在的本地库 .m2 目录删掉,然后把m2bak修改成 .m2 名字。就可以在eclipse中新建maven项目了。

wangxiaolei

赞同来自: Mr_niu

你的maven没有配置训练营的提供的mirror,直接连的国外的服务器,可能是因为网络原因本地maven库下载的文件不全,就是/root/.m2/这个目录下少文件。
我把我的maven本地库.m2这个目录全部复制到你的机器上,就可以新建maven项目。

fish - Hadooper

赞同来自: Mr_niu

可以在/conf/settings.xml中配置mirror,以避免网络问题:
    
   
      chinahadoop.central
      central
      ChinaHadoop central Mirror.
      http://DX2:8081/nexus/content/repositories/central/
   

   

fish - Hadooper

当直接执行mvn命令的时候,会从当前目录寻找项目的配置文件pom.xml。
你图形界面中执行的这个命令,并不是在项目所在的目录对吧?直接执行mvn发生的这样的错误,在字符终端也同样会出现。
 
至于eclipse,应该是另有原因,你做了什么样的操作报的错误?
就是这样的一个新建步骤
还用你原来,不配置镜像的情况。
执行命令mvn -B archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DgroupId=com.mycompany.app -DartifactId=my-app
然后等36分钟,最后显示失败。失败信息中很容易发现,Read timed out。
超时导致jar包没有下载成功,如 maven-archetype-plugin:2.4:generate (default-cli)
下面就是执行命令后的失败信息:

------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 36:49 min
Finished at: 2016-03-28T18:00:58+08:00
Final Memory: 9M/28M
------------------------------------------------------------------------
Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:generate (default-cli) on project standalone-pom: Execution default-cli of goal org.apache.maven.plugins:maven-archetype-plugin:2.4:generate failed: Plugin org.apache.maven.plugins:maven-archetype-plugin:2.4 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.apache.velocity:velocity:jar:1.5, backport-util-concurrent:backport-util-concurrent:jar:3.1, org.codehaus.groovy:groovy:jar:1.8.3, antlr:antlr:jar:2.7.7: Could not transfer artifact org.apache.velocity:velocity:jar:1.5 from/to central (https://repo.maven.apache.org/maven2): GET request of: org/apache/velocity/velocity/1.5/velocity-1.5.jar from central failed: Read timed out ->

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

要回复问题请先登录注册