今天我在我的 eclipse 中导入了一个 Maven 项目。当我尝试使用自动建议时,当我添加一些代码时,它提醒我“编译单元不在 Java 项目的构建路径上”。我看到这个问题的解决方法很少,但都没有解决。这个应该怎么办?
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.core.extension</groupId>
<artifactId>Softpro</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>cu-softpro-connector</artifactId>
<name>jar :: cu-softpro-connector</name>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.core.extension</groupId>
<artifactId>cu-softpro-client</artifactId>
</dependency>
<dependency>
<groupId>com.core.framework</groupId>
<artifactId>cu-svcframework-ejb</artifactId>
<type>ejb</type>
</dependency>
<dependency>
<groupId>com.core.framework</groupId>
<artifactId>cu-shared</artifactId>
</dependency>
<dependency>
<groupId>com.core.base</groupId>
<artifactId>cu-common-entity</artifactId>
</dependency>
<dependency>
<groupId>com.core.base</groupId>
<artifactId>cu-services-base</artifactId>
<exclusions>
<exclusion>
<groupId>com.core.framework</groupId>
<artifactId>cu-subsystems</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.core.base</groupId>
<artifactId>cu-platform-model</artifactId>
</dependency>
<dependency>
<groupId>com.core.extension</groupId>
<artifactId>cu-forms-connector</artifactId>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-core</artifactId>
</dependency>
</dependencies>
</project>
最佳答案
我在导入时遇到了与 maven 项目相同的问题。
根本原因:
我通过按 Ctrl+Shift+R 搜索文件并在 Parent -> Sub-module -> FileName.java 路径上打开文件。所以按下 Ctrl+Space 时出现错误 The compilation unit is not on the build path of a Java project - Maven
解决方案:
我们需要确保我们在子模块路径上打开文件,并且构建路径应该配置为项目中安装的正确 jdk。
希望这对您有所帮助。
关于java - 编译单元不在 Java 项目的构建路径上 - Maven,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37803889/