简体   繁体   English

Eclipse Java 缺少所需的源文件夹:'src'

[英]Eclipse Java Missing required source folder: 'src'

I imported a jar file into workspace and this is the error I get:我将一个 jar 文件导入到工作区,这是我得到的错误:

Description Resource Path Location Type说明 资源路径 位置类型
Project 'Interpreter1' is missing required source folder: 'src' Interpreter1 Build path Build Path Problem项目“Interpreter1”缺少所需的源文件夹:“src” Interpreter1 Build path Build Path Problem

How can i get rid of this error?我怎样才能摆脱这个错误?

Right-Click Project --> Build Path --> Configure Build Path;右键项目-->构建路径-->配置构建路径; unselect the SRC, save, select again.取消选择SRC,保存,再次选择。

This solved my problem.这解决了我的问题。

Go to the Build Path dialog ( right-click project > Build Path > Configure Build Path ) and make sure you have the correct source folder listed, and make sure it exists.转到Build Path对话框( right-click project > Build Path > Configure Build Path )并确保列出了正确的源文件夹,并确保它存在。

The source folder is the one that holds your sources, usuglaly in the form: project/src/com/yourpackage/...源文件夹是保存源的文件夹,通常采用以下形式: project/src/com/yourpackage/...

右键项目 -> 新建 -> 文件夹 -> 文件夹名称:src -> 完成

Edit your .classpath file.编辑您的 .classpath 文件。 (Or via the project build path). (或通过项目构建路径)。

Here's what worked for me: right click the project-> source -> format After that just drag and drop the source folder into eclipse under the project and select link.这对我有用:右键单击项目-> 源-> 格式之后,只需将源文件夹拖放到项目下的 eclipse 中并选择链接。

good luck!祝你好运!

I was confused by this for hours.我对此困惑了几个小时。

Right click on project -> Build Path -> Configure Build Path -> Add Folder右键单击项目-> 构建路径-> 配置构建路径-> 添加文件夹

One of the build path issue is it cannot find the correct /src/conf source folder.构建路径问题之一是找不到正确的 /src/conf 源文件夹。 Right click on each project, Build Path > Configure Build Path.右键单击每个项目,构建路径 > 配置构建路径。 Under the Source tab, remove the folder with a red cross icon on the bottom right.在“源”选项卡下,删除右下角带有红色十字图标的文件夹。 It will work for the situation that there is a small red exclamation mark “!“ bedore your project name!它适用于您的项目名称有一个小的红色感叹号“!”的情况!

在项目中创建 src 文件夹。

右键项目-->构建路径-->配置构建路径-->源-->(选择丢失的文件夹或路径)-->添加文件夹-->应用-->确定

If you are facing an error with the folder, such as src/test/java or src/test/resources, just do a right click on the folder and then create aa new folder with the name being src/test/java.如果您遇到文件夹错误,例如 src/test/java 或 src/test/resources,只需右键单击该文件夹,然后创建一个名为 src/test/java 的新文件夹。 This should solve your problem.这应该可以解决您的问题。

In eclipse, you must be careful to create a "source folder" (File->New->Source Folder).在eclipse中,一定要注意创建“源文件夹”(File->New->Source Folder)。 This way, it's automatically on your classpath, and, more importantly, Eclipse knows that these are compilable files.这样,它会自动在您的类路径中,而且更重要的是,Eclipse 知道这些是可编译的文件。 It's picky that way.这样很挑剔。

I think it's because of the .classpath getting saved with the deleted source folder configuration.我认为这是因为 .classpath 与已删除的源文件夹配置一起保存。

  1. Create the missing folder [ ' src ' in your case] manually inside the root of the project.在项目的根目录中手动创建丢失的文件夹 [ ' src ' in your case]。 When I say manually, I meant outside Eclipse, using the file explorer.当我说手动时,我的意思是在 Eclipse 之外,使用文件资源管理器。

  2. Then, come back to eclipse and refresh the project.然后,回到 eclipse 并刷新项目。 Now, the error saying it's already there will be gone.现在,说它已经存在的错误将消失。

  3. Now, Right click on the project > Build Path > Configure Build path .现在,右键单击项目>构建路径>配置构建路径 It should take us to the Java build path side menu.它应该将我们带到Java 构建路径侧菜单。

  4. Make sure we are on the ' Source ' tab.确保我们位于“”选项卡上。 Delete the source folder causing the problem.删除导致问题的源文件夹。 Now, maybe the folder might show up in the project structure and you may delete that too.现在,也许该文件夹可能会出现在项目结构中,您也可以将其删除。

Eclipse wouldn't let me point to an existing (or add a new) source directory. Eclipse 不会让我指向现有的(或添加新的)源目录。 Eclipse's configuration files can be wonky. Eclipse 的配置文件可能很不稳定。 In my case I should have started simple.就我而言,我应该从简单开始。 Right click the project and click Refresh.右键单击项目,然后单击刷新。

In my case eclipse reported this in the Problems view on the parent project which does not have any code.在我的情况下,eclipse 在没有任何代码的父项目的问题视图中报告了这一点。 I just delete the error whenever it is reported on this parent project where src folder is really not needed.每当在确实不需要 src 文件夹的父项目上报告错误时,我都会删除该错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM