刚刚下载maven,解压后,配好环境,compile后,出现问题:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building jhope.core 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-cli) @ jhope.core ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.475 s
[INFO] Finished at: 2016-02-28T00:31:50+08:00
[INFO] Final Memory: 8M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install (default-cli) on project jhope.core: The packaging for this project did not assign a file to the build artifact -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Process finished with exit code 1
==================================================================================
未配置maven的http代理。检车是否是此类问题、以及解决如下:
有时候你所在的公司基于安全因素考虑,要求你使用通过安全认证的代理访问因特网。这种情况下,就需要为Maven配置HTTP代理,才能让它正常访问外部仓库,以下载所需要的资源。首先确认自己无法直接访问公共的maven中央仓库,直接运行命令ping repo1.maven.org可以检查网络。如果真的需要代理,先检查一下代理服务器是否畅通。比如现在有一个IP地址为218.14.227.197,端口为3128的代理服务,我们可以运行telnet 218.14.227.197 3128来检测该地址的该端口是否畅通。如果得到出错信息,需要先获取正确的代理服务信息,如果telnet连接正确,则输入ctrl+],然后q,回车,退出即可。
检查完毕之后,编辑~/.m2/settings.xml文件(如果没有该文件,则复制$M2_HOME/conf/settings.xml)。添加代理配置如下:
- <settings>
- ...
- <proxies>
- <proxy>
- <id>my-proxy</id>
- <active>true</active>
- <protocol>http</protocol>
- <host>218.14.227.197</host>
- <port>3128</port>
- <!--
- <username>***</username>
- <password>***</password>
- <nonProxyHosts>
- repository.mycom.com|*.google.com
- </nonProxyHosts>
- -->
- </proxy>
- </proxies>
- ...
- </settings>
<proxy>
<!--id是代理名称-->
<id>my-proxy</id>
<!--active表示激活代理-->
<active>true</active>
<!--protocol表示使用的代理协议-->
<protocol>http</protocol>
<!--代理主机名-->
<host>192.168.1.95</host>
<!--代理主机端口-->
<port>9001</port>
<!--代理认证用户名-->
<username>***</username>
<!--代理认证密码-->
<password>***</password>
<!--指定哪些主机名不需要代理
<nonProxyHosts>repository.mycom.com|*.google.com</nonProxyHosts>
-->
</proxy>
这段配置十分简单,proxies下可以有多个proxy元素,如果声明了多个proxy元素,则默认情况下第一个被激活的proxy会生效。这里声明了一个id为my-proxy的代理,active的值为true表示激活该代理,protocol表示使用的代理协议,这里是http。当然,最重要的是指定正确的主机名(host元素)和端口(port元素)。上述xml配置中注释掉了username,password,nonProxyHosts几个元素。当代理服务需要认证时,就需要配置username和password。nonProxyHost元素用来指定哪些主机不需要代理,可以使用"|"符号来分隔多个主机名。此外,该配置也支持通配符,如:*.google.com表示所有以google.com结尾的域名访问都不要通过代理。