[英]How can I make eclipse detect my new java class in my m2e maven project?
I have started looking into Maven and wish to build a project from scratch and start writing new classes. 我已经开始研究Maven,并希望从头开始构建一个项目并开始编写新类。
What do I need to do to make eclipse's auto compilation work under a Maven project in the same way as it does in a normal eclipse project? 我需要做些什么来使Eclipse在Maven项目下的自动编译工作与在普通Eclipse项目中的工作相同?
Here is the problem I am facing: 这是我面临的问题:
I have created a new project in eclipse with the m2e plugin. 我已经使用m2e插件在eclipse中创建了一个新项目。
I am using the quickstart archetype, which generates a simple project structure with a main folder and a test folder. 我正在使用quickstart原型,该原型会生成一个带有主文件夹和测试文件夹的简单项目结构。 Initially the main folder contains a java file called App.java (under the package specified during setup).
最初,主文件夹包含一个名为App.java的Java文件(在安装过程中指定的软件包下)。
Now I add a new class in the same package as App.java, say "Other" in the file Other.java, add a public constant to it, and open up App.java for editing. 现在,我在与App.java相同的程序包中添加一个新类,在文件Other.java中说“ Other”,为其添加一个公共常量,然后打开App.java进行编辑。 When I try to reference the class Other, eclipse does not recognise it.
当我尝试引用其他类时,eclipse无法识别它。
I have run Maven compile via eclipse and double checked that the build path output folders are correct, but everything is as it should be. 我已经通过Eclipse运行了Maven编译,并再次检查了构建路径输出文件夹是否正确,但是一切都应该如此。
I have searched through countless tutorials on Maven and Eclipse, but all the ones I have found only talk about setting up the project, not about actually developing under a Maven project. 我搜索了无数有关Maven和Eclipse的教程,但是我发现的所有教程仅谈论设置项目,而不是实际在Maven项目下进行开发。
My Eclipse is standard edition Kepler, and I am using eclipse's embedded maven installation. 我的Eclipse是标准版的开普勒,我正在使用eclipse的嵌入式maven安装。
It seems my workspace may have been corrupted. 看来我的工作区可能已损坏。
I did the following things, one of which will have made the difference. 我做了以下事情,其中之一会有所作为。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.