Maven:没有可编译的源代码 [英] Maven: No sources to compile

查看:114
本文介绍了Maven:没有可编译的源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注使用 Maven 构建 Java 项目"(https://spring.io/guides/gs/maven/#scratch) 并且当我从/Users/Misha/Desktop/src/main/java/hello 运行 'mvn compile' 时,我得到这个提示:

I am following the 'Build Java Projects with Maven' (https://spring.io/guides/gs/maven/#scratch) and when I run 'mvn compile' from /Users/Misha/Desktop/src/main/java/hello, I get this prompt:

[INFO] Scanning for projects...   
[INFO]                                                                                  
[INFO] ------------------------------------------------------------------------   
[INFO] Building gs-maven 0.1.0    
[INFO] ------------------------------------------------------------------------   
[INFO]    
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ gs-maven ---   
[INFO] Using 'UTF-8' encoding to copy filtered resources.   
[INFO] Copying 3 resources   
[INFO]    
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ gs-maven ---   
[INFO] No sources to compile   
[INFO] ------------------------------------------------------------------------   
[INFO] BUILD SUCCESS     
[INFO] ------------------------------------------------------------------------    
[INFO] Total time: 0.942 s    
[INFO] Finished at: 2015-01-11T23:10:28-08:00   
[INFO] Final Memory: 7M/155M
[INFO] ------------------------------------------------------------------------

我在 hello 目录中有两个 java 文件和 xml 文件,我假设我应该看到Hello World!"而不是没有要编译的来源.为什么我的java代码没有编译?谢谢!

I have the two java files and the xml file in the hello directory, and I am assuming that I should see "Hello World!" instead of No sources to compile. Why is my java code not compiling? Thanks!

推荐答案

要创建一个你需要的 Maven 项目

To create a maven-project you need

  1. 包含 pom.xml-file 的项目目录
  2. 在此项目目录中的子目录 src/main/java 包含您的 java 代码(包转到 src/main/java 的子目录)
  1. A project-directory containing the pom.xml-file
  2. Within this project-directory a subdirectory src/main/java containing your java-code (packages go to subdirectories of src/main/java)

从项目目录中调用 maven run mvn compile 或类似的东西.

To invoke maven run mvn compile or something similar from the project-directory.

这篇关于Maven:没有可编译的源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆