【问题标题】:Does a pom.xml.template tell me everything I need to know to use the project as a dependencypom.xml.template 是否告诉我将项目用作依赖项所需知道的一切
【发布时间】:2010-09-15 04:48:29
【问题描述】:

我正在尝试将名为 term-highlighter 的 lucene 沙箱贡献添加到我的 pom.xml 中。 我对 Maven 不是很熟悉,但是代码中有一个 pom.xml.template 似乎暗示如果我添加一个看起来像这样的依赖项:

<dependency>
  <groupId>org.apache.lucene</groupId>
  <artifactId>lucene-highlighter</artifactId>
</dependency>

它可能会起作用。有人可以帮我在我的 pom.xml 文件中添加一个 lucene-community 项目吗?

感谢 cmets,原来我只需要添加版本,我只是猜测它应该与我使用的 lucene-core 版本匹配。:

<dependency>
    <groupId>org.apache.lucene</groupId>
    <artifactId>lucene-highlighter</artifactId>
    <version>2.3.1</version>
</dependency>

【问题讨论】:

    标签: lucene maven-2 lucene-highlighter


    【解决方案1】:

    您说得对,但您可能还想添加版本:

    From The Maven 5 minute tutorial

    <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>com.mycompany.app</groupId>
      <artifactId>my-app</artifactId>
      <packaging>jar</packaging>
      <version>1.0-SNAPSHOT</version>
      <name>Maven Quick Start Archetype</name>
      <url>http://maven.apache.org</url>
    
      <dependencies>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>3.8.1</version>
          <scope>test</scope>
        </dependency>
      </dependencies>
    
    </project>
    

    【讨论】:

      【解决方案2】:

      您必须添加版本号,但您只需在项目结构中添加一次。也就是说,如果在父 pom 中定义了版本号,则不必再次提供版本号。 (但在这种情况下,您甚至不必提供依赖项,因为无论如何都会继承依赖项。)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2022-08-10
        • 2020-08-24
        • 1970-01-01
        • 2020-02-12
        • 2010-10-28
        • 2023-03-11
        • 1970-01-01
        • 2019-08-13
        相关资源
        最近更新 更多