使用maven,为pom添加依赖并下载它?

时间:2015-07-21 12:54:34

标签: java maven

这是一个非常简单的问题,但我搜索了一个解决方案,没有任何对我有用。我将以下内容添加到我的pom.xml中,但无法在org.apache.commons.csv.CSVParser中导入class。当我运行mvn install时,我得到以下输出。

<dependencies> 
      ....

    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-csv</artifactId>
        <version>1.1.1-SNAPSHOT</version>
    </dependency>

    ....
 </dependencies>

D:\java\my_project>mvn install    
[INFO] Scanning for projects...    
[INFO] Building my_project 1.0-SNAPSHOT

[WARNING] The POM for org.apache.commons:commons-csv:jar:1.1.1-SNAPSHOT is missing, no dependency information available

[INFO] BUILD FAILURE    

[INFO] Total time: 0.644 s    
[INFO] Finished at: 2015-07-21T08:46:47-04:00    
[INFO] Final Memory: 8M/245M    

[ERROR] Failed to execute goal on project my_project: Could not resolve depen dencies for project com.myproject:artifact:jar:1.0-SNAPSHOT: Could not find artifact org.apache.commons:commons-csv:jar:1.1.1-SNAPSHOT -> [Help 1]  
[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] For more information about the errors and possible solutions, please read the following articles:    
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException nException

1 个答案:

答案 0 :(得分:7)

为什么使用快照?快照版本是alpha / beta版本,可能不稳定。它也没有上传到标准的Maven仓库,所以你需要做一些额外的工作才能使用它。如果你使用1.1它应该工作。

<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-csv</artifactId>
    <version>1.1</version>
</dependency>