今天我在日食中导入了一个Maven项目。当我尝试使用Auto建议时,当我添加一些代码时,它会警告我"编译单元不在Java项目的构建路径上#34;。我看到这个问题的解决方法很少,但没有一个解决。该怎么办?
<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>
答案 0 :(得分:2)
我在导入时遇到了与maven项目相同的问题。
根本原因:
我按 Ctrl + Shift + R 搜索文件,然后在父级 - &gt;上的路径上打开文件。子模块 - &gt; FileName.java 。在按Ctrl + Space的同时它给出了错误编译单元不在Java项目的构建路径上 - Maven
<强>解决方案:强>
我们需要确保在子模块路径上打开文件,并且还应该将构建路径配置为项目中安装的正确jdk。
希望这有帮助。
答案 1 :(得分:1)
在Eclipse中打开多模块Maven项目时,您会在project explorer
正常
- parent-module
- sub-module1
- src
- main
- java
- YourClass <-- the one with the framed J icon
+ sub-module2
- sub-module1
- src
- main
- java
- YourClass <-- the one with the solid J icon
图标在http://help.eclipse.org/luna/index.jsp?topic=/org.eclipse.jdt.doc.user/reference/ref-icons.htm解释。
要将Maven项目导入Eclipse,请遵循以下文档Importing Maven Projects。