gpt4 book ai didi

java - 编译单元不在 Java 项目的构建路径上

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:55:53 25 4
gpt4 key购买 nike

我加入了一个 SVN 服务器,并从该服务器 check out 了一个项目的源文件。在 Eclipse 编辑器中,当我按下 Ctrl + Space 时,我收到以下错误消息:

This compilation unit is not on the build path of a Java project

This compilation unit is not on the build path of a Java project

我应该怎么做才能解决这个问题?

最佳答案

阅读本指南,了解如何在 eclipse 中使用 maven 项目

http://maven.apache.org/guides/mini/guide-ide-eclipse.html

取自以上链接:

您收到该通知的原因:

Eclipse needs to know the path to the local maven repository. Therefore the classpath variable M2_REPO has to be set.

解决方案

执行以下命令:

mvn -Declipse.workspace=<path-to-eclipse-workspace> eclipse:add-maven-repo

Restart your Eclipse IDE (if you already have it open) for this change to take effect. You can also define a new classpath variable inside eclipse: From the menu bar, select Window > Preferences. Select the Java > Build Path > Classpath Variables page

对于简单项目:

If you have a simple java project which is made up of only one module, using eclipse is very simple. To generate the eclipse project files from your POM you execute the following command:

mvn eclipse:eclipse

If you have created or checked out the project with eclipse, you only have to refresh the project in your workspace. Otherwise you have to import the project into your eclipse workspace (From the menu bar, select File >Import >Existing Projects into Workspace). In the latter case the project (directory) should not be located in your workspace, because eclipse might come into trouble, especially if you want to use eclipse as the scm client.

有关更详细的说明,请参阅上面的链接。

关于java - 编译单元不在 Java 项目的构建路径上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19652313/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com