【问题标题】:Maven says that there is now dependency despite the fact that it existsMaven 说,尽管存在依赖,但现在存在依赖
【发布时间】:2013-03-21 15:31:25
【问题描述】:

我有一个包含两个模块的项目,我需要在另一个模块中使用第一个模块中的类。为此,我在第一个的 pom 文件中添加了依赖项:

<dependency>
      <groupId>com.mdnaRabbit.worker</groupId>
      <artifactId>Worker</artifactId>
      <version>1.0-SNAPSHOT</version>
  </dependency>

当我尝试添加的模块的 pom 如下:

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

    <parent>
        <artifactId>DLP</artifactId>
        <groupId>com.messagedna.dlp</groupId>
        <version>1.0</version>
    </parent>
    <groupId>com.mdnaRabbit.worker</groupId>
  <artifactId>Worker</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>Worker</name>

当我像这样将类导入第一类时:

import com.mdnaRabbit.worker.data.Data;

并尝试执行打包我有以下跟踪:

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/mikhail/bzrrep/DLP/NewTask/src/main/java/com/mdnaRabbit/newt/App.java:[9,33] error: package com.mdnaRabbit.worker.data does not exist
[ERROR] /home/mikhail/bzrrep/DLP/NewTask/src/main/java/com/mdnaRabbit/newt/App.java:[39,19] error: cannot find symbol
[ERROR]  class App
/home/mikhail/bzrrep/DLP/NewTask/src/main/java/com/mdnaRabbit/newt/App.java:[27,12] error: cannot find symbol
[ERROR]  class App
/home/mikhail/bzrrep/DLP/NewTask/src/main/java/com/mdnaRabbit/newt/App.java:[40,8] error: cannot find symbol
[ERROR]  class App
/home/mikhail/bzrrep/DLP/NewTask/src/main/java/com/mdnaRabbit/newt/App.java:[40,24] error: cannot find symbol
[INFO] 5 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure

导入字符串没有红色下划线

【问题讨论】:

  • 你有没有在你依赖的项目上运行'mvn install'?
  • 你是在构建父模块还是子模块?你曾经在 Worker 模块上执行过 mvn install 吗?
  • 哦,尼尔斯,谢谢。我总是忘记运行“mvn install”。
  • 你需要告诉你,你是 maven 的新手。
  • 你是完全正确的。我完全是编程新手。

标签: java maven intellij-idea


【解决方案1】:

已解决:我需要运行“mvn install”

【讨论】:

    【解决方案2】:

    也许这会有所帮助。

    <plugin>
        <groupId>com.mdnaRabbit.worker</groupId>
        <artifactId>WORKER</artifactId>
        <version>1.0-SNAPSHOT</version>
        <configuration>
              <!-- parameters and values common to all goals, as required -->
        </configuration>
    </plugin>
    

    或者尝试手动安装。

    【讨论】:

      猜你喜欢
      • 2021-11-23
      • 2011-04-11
      • 2015-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-11
      • 1970-01-01
      • 2017-07-27
      相关资源
      最近更新 更多