更新时间:2023-11-17 23:39:34
项目目录结构与默认的Maven目录结构不匹配. Maven希望源位于根文件夹(包含pom.xml
的文件夹)下的src/main/java
目录中.来源在src
文件夹中,因此出现No sources to compile
错误.
The project directory structure does not match with the default Maven directory structure. Maven expects the source to be in src/main/java
directory under the root folder (the folder containing pom.xml
). The source here is in the src
folder hence the No sources to compile
error.
您可以移动源以使用默认的Maven目录结构,也可以通过将以下内容添加到pom的build
部分中来更改pom.xml
以显式指定源目录:
You can either move your sources to use the default Maven directory structure or change the pom.xml
to explicitly specify your source directory by adding the following to the build
section of the pom:
<sourceDirectory>${basedir}/src</sourceDirectory>
More info on Maven's standard directory layouts can be found here.