问题描述
我正在使用Maven构建我的项目。当我在Eclipse中查看它时,它抱怨说Maven能够成功地构建项目。
Eclipse需要识别某个文件夹作为源文件夹,以便将内容正确解释为Java源文件。
通常,如果创建一个Java项目,Eclipse会创建一个名为src的文件夹并将其标记为源文件夹。但是,如果您正在处理默认的Maven项目设置,Eclipse将不会自动识别src / main / java作为源文件夹(除非您正在使用插件)。
如果您不确定Eclipse是否将文件夹视为源文件夹或只是常规文件夹,请查看图标(请注意左下角的小包装符号):
正如你所说,正如你所说,使用Maven,你应该使用一个Maven插件给Eclipse,或者让Maven为Eclipse生成所需的元文件。这可以通过命令(生成.classpath和.project文件)完成:
未使用Maven但面临此问题的人可以右键单击源文件夹,并将其标记为源文件夹,其中包含构建路径 - >使用为源文件夹'。
I am using Maven to build my project. When I view it in Eclipse, it complains that
Maven is able to successfully build the project though.
Eclipse needs to recognize a certain folder as a 'Source Folder' in order to correctly interpret the contents as Java source files.
Typically, if you create a Java project, Eclipse creates one folder called 'src' and marks it as 'Source Folder'. If you are dealing with a default Maven project setup, however, Eclipse will not automagically recognize 'src/main/java' as a source folder (unless you are using a plugin of course).
If you are not sure whether Eclipse sees your folder as a 'Source Folder' or just a regular folder, take look at the icons (note the small package symbol on the lower left corner):
Since you are, as you stated, working with Maven, you should either use a Maven plugin for Eclipse or have Maven generate the required meta-files for Eclipse. This can be done with the command (generates .classpath and .project files):
People who are not using Maven, but face this issue, can right-click on their source folder and mark it as source folder with 'Build Path -> Use as source folder'.
这篇关于Eclipse说包装声明不符合预期的包装“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!