我有一个包含两个模块的项目,我需要使用另一个模块中的第一个类。为此,我将依赖项添加到第一个的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
导入字符串没有用红色加下划线
答案 0 :(得分:0)
解决了:我需要运行“mvn install”
答案 1 :(得分:0)
也许这会有所帮助。
<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>
或尝试手动安装。