在使用maven过程中出现的问题(1)——运行mvn compile报错

第一次用maven创建项目,运行mvn compile报错

[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its
 dependencies could not be resolved: Failed to read artifact descriptor for org.
apache.maven.plugins:maven-resources-plugin:jar:2.6: Could not transfer artifact
 org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from/to central (https:
//repo.maven.apache.org/maven2): Received fatal alert: protocol_version -> [Help
 1]


[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its
 dependencies could not be resolved: Failed to read artifact descriptor for org.
apache.maven.plugins:maven-resources-plugin:jar:2.6: Could not transfer artifact
 org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from/to central (https:
//repo.maven.apache.org/maven2): repo.maven.apache.org: Unknown host repo.maven.
apache.org -> [Help 1]

开始真的是一头雾水,在网上查找解决办法,
1、有的说缺少依赖,直接在pom文件中添加依赖添加链接描述
<dependency> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.6</version> </dependency>

2、有的说原因是maven的中央仓库没法访问
解决方法是修改conf/settings.xml,设mirror为http://mirrors.ibiblio.org/pub/mirrors/maven2


我的解决办法就是卸载了原来的maven3.5.2,重新下载解压了一个maven3.2.2------------可能是版本的问题,也可能是当时配置有稍许问题…???

其他见参考:maven compile问题解决

使用Maven命令创建项目

发布了9 篇原创文章 · 获赞 6 · 访问量 1万+
展开阅读全文

maven compile遇到的问题

08-03

我按照maven文件的约定结构写了一个Hello world,但是在运行mvn compile命令的时候出现了问题,求大神解答: ![文件结构](https://img-ask.csdn.net/upload/201508/03/1438617414_786055.png) HelloWorld.java ``` package cn.ac.imicams.maven01.model; public class HelloWorld{ public String sayHello(){ return "Hello World!"; } } ``` HelloWorldTest.java ``` package cn.ac.imicams.maven01.model; import org.junit.*; import org.junit.Assert.*; public class HelloWorldTest{ @Test public void testHello(){ Assert.assertEquals("Hello World!", new HelloWorld().sayHello()); } } ``` pom.xml ``` <?xml version="1.0" encoding="UTF-8"?> 、 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupID>cn.ac.imicams.maven01</groupID> <artifactID>maven01-model</artifactID> <version>0.0.1SNAPSHOT</version> <dependencies> <dependency> <groupID>junit</groupID> <artifactID>junit</artifactID> <version>4.10</version> </dependency> </dependencies> </project> ``` 错误代码如下: ``` E:\code\maven01>mvn compile [INFO] Scanning for projects... [ERROR] [ERROR] Some problems were encountered while processing the POMs: [FATAL] Non-parseable POM E:\code\maven01\pom.xml: only whitespace content allowed before start tag and not \u3001 (position: START_DOCUMENT seen <?xml version="1.0" encoding="UTF-8"?>\n\u3001... @2:2) @ line 2, column 2 @ [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project (E:\code\maven01\pom.xml) has 1 error [ERROR] Non-parseable POM E:\code\maven01\pom.xml: only whitespace content allowed before start tag and not \u3001 (position: START_DOCUMENT seen <?xml version="1.0" encoding="UTF-8"?>\n\u3001... @2:2) @ line 2, column 2 -> [Help 2] [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/ProjectBuildingException [ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException ``` 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 编程工作室 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览