我有一个包含两个模块的项目,我需要在另一个模块中使用第一个模块中的类。为此,我在第一个的 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
导入字符串没有红色下划线