pom.xml.template 是否告诉我使用项目作为依赖项所需知道的一切

发布于 2024-07-06 07:17:58 字数 904 浏览 4 评论 0原文

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

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

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

感谢您的评论,事实证明添加版本就是我所需要的,我只是猜测它应该与我正在使用的 lucene-core 版本相匹配:

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

I'm trying to add the lucene sandbox contribution called term-highlighter to my pom.xml.
I'm not really that familiar with Maven, but the code has a pom.xml.template which
seems to imply if I add a dependency that looks like:

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

It might work. Can someone help me out in adding a lucene-community project to my pom.xml file?

Thanks for the comments, it turns out that adding the version was all I needed, and I just guessed it should match the lucene-core version I was using.:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

伴随着你 2024-07-13 07:17:58

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

You have to add the version number, but you only have to do it once in a project structure. That is, if the version number is defined in a parent pom, you don't have to give the version number again. (But you don't even have to provide the dependency in this case since the dependency will be inherited anyways.)

去了角落 2024-07-13 07:17:58

你说得对,但你可能也想添加版本:

来自 Maven 5 分钟教程

<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>

You have it right, but you probably want to add the version as well:

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文