本文介绍了编译单元不在Java项目的构建路径--Maven的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我在我的日食中导入了一个Maven项目。当我尝试去Auto建议时,当我添加一些代码时,它会提醒我:编译单元不在Java项目的构建路径上。我看到这个问题的解决方法很少,但没有一个解决。这个应该做什么?

Today I've imported a Maven project in my eclipse. When I try to go for Auto suggest, when I was adding some code, it alerts me as "The compilation unit is not on the build path of a Java project". I saw few workarounds for this issue, but none of them solved. What should be done for this one?

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


推荐答案

当您在Eclipse中打开多模块Maven项目您在项目资源管理器中看到通常

When you open a multi-module Maven project in Eclipse you see in the project explorer normally

- 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

framed J图标

solid J图标

framed J icon
solid J icon

图标在。

要将Maven项目导入到Eclipse中,请遵循以下文档:。

To import a Maven project into Eclipse follow this documentationImporting Maven Projects.

这篇关于编译单元不在Java项目的构建路径--Maven的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 20:06