[英]Why I can't use New->Source Folder in a new created maven webapp project in Eclipse?
I created a new maven webapp project in Eclipse, and there is src/main/resources folder and no src/main/java, so I right-clicked on the project folder and choose "New"->"Source Folder". 我在Eclipse中创建了一个新的maven webapp项目,并且有src / main / resources文件夹而没有src / main / java,所以我右键单击项目文件夹并选择“New” - >“Source Folder”。 When I type "src/main/java" I just get an error: 当我输入“src / main / java”时,我得到一个错误:
The folder is already a source folder. 该文件夹已是源文件夹。
and I found in my project's "Java Build Path" property there is a configuration of src/main/java 我在我的项目的“Java Build Path”属性中找到了src / main / java的配置 why the project have this configuration while there is no such folder like src/main/java? 为什么项目有这个配置,而没有像src / main / java这样的文件夹?
Create the folder as an ordinary folder using New > Folder
. 使用New > Folder
将文件夹创建为普通文件New > Folder
。 Eclipse will know it's a source folder when it's in a Maven project. Eclipse会在Maven项目中知道它是一个源文件夹。
This is a somewhat weird situation when Eclipse internally recognizes src/main/java
as a source folder because Maven says it's a source folder even though the folder does not actually exist. 当Eclipse 内部将src/main/java
识别为源文件夹时,这有点奇怪,因为Maven说它是源文件夹,即使该文件夹实际上并不存在。 Because it does not exist, you won't see it listed as a source folder in project browser / package explorer - but you'll be given this error when you try to create it. 因为它不存在,所以您不会在项目浏览器/包浏览器中看到它被列为源文件夹 - 但是当您尝试创建它时,您将收到此错误。 In the moment you create the folder as an ordinary folder, Eclipse will realize this is the missing source folder and list it as such in GUI. 在您将文件夹创建为普通文件夹的那一刻,Eclipse将意识到这是缺少的源文件夹,并在GUI中将其列出。
I think you get the error because the folder does not exist. 我认为你得到错误,因为该文件夹不存在。 Just create the folder and then right click on the folder and select 只需创建文件夹,然后右键单击该文件夹并选择
Build Path -> Use as source folder
If that doesn't work just remove the folders that say "missing" and do the above procedure on the actual folders 如果这不起作用,只需删除说“丢失”的文件夹,然后对实际文件夹执行上述步骤
This is absurd, but following worked for me: 这很荒谬,但以下为我工作:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.