简体   繁体   English

Maven没有检测到项目依赖

[英]Maven isn't detecting project dependencies

For some reason, I cannot get maven to list or download a dependency for a fresh project. 由于某些原因,我无法让Maven列出或下载新项目的依赖项。 I have used this particular dependency before so I'm not sure why it isn't working now. 我以前使用过这种特殊的依赖关系,所以我不确定为什么现在不能使用。 From my pom file: 从我的pom文件中:

<properties>
    <splunksdk.version>1.3.0</splunksdk.version>
</properties>

<repositories>
    <repository>
        <id>ext-release-local</id>
        <url>http://splunk.artifactoryonline.com/splunk/ext-releases-local</url>
    </repository>
</repositories>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.splunk</groupId>
            <artifactId>splunk</artifactId>
            <version>${splunksdk.version}</version>
        </dependency>
    </dependencies>
</dependencyManagement>

Yet, when I try mvn dependency:resolve it doesn't find anything. 但是,当我尝试使用mvn dependency:resolve它什么也找不到。 (I've checked ~/.m2/repository/ directory and its still empty.) (我检查了〜/ .m2 / repository /目录,它仍然为空。)

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Splunk Scrapper 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.1:resolve (default-cli) @ SplunkScrapper ---
[INFO] 
[INFO] The following files have been resolved:
[INFO]    none
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.906s
[INFO] Finished at: Wed Sep 17 16:27:25 MDT 2014
[INFO] Final Memory: 8M/239M
[INFO] ------------------------------------------------------------------------

I can't get a mvn dependency:tree to print anything either. 我也无法获得mvn dependency:tree来打印任何内容。

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Splunk Scrapper 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ SplunkScrapper ---
[INFO] com.company.project:SplunkScrapper:jar:0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.096s
[INFO] Finished at: Wed Sep 17 16:28:46 MDT 2014
[INFO] Final Memory: 8M/236M
[INFO] ------------------------------------------------------------------------

Is there something that I'm doing wrong? 我做错什么了吗? I can't spot anything obvious so I'm not sure why it isn't resolving. 我看不到任何明显的东西,所以我不确定为什么它无法解决。

The <dependencyManagement> tag is not used for defining what dependencies you need. <dependencyManagement>标记不用于定义所需的依赖项。 Its used to specify how to configure a dependency (which version, scope, etc) if it is found on the dependencies for a project. 如果在项目的依赖项上找到依赖项,则用于指定如何配置依赖项(哪个版本,范围等)。

To define the actual dependencies you need to use the <dependencies> tag: 要定义实际的依赖关系,您需要使用<dependencies>标记:

   <dependencies>
      <dependency>
        <groupId>com.splunk</groupId>
        <artifactId>splunk</artifactId>
       </dependency>
   </dependencies> 

See differences between dependencymanagement and dependencies in maven for more information. 有关更多信息,请参见maven中的依赖关系管理和依赖关系之间的差异

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM