[英]m2e plugin - Eclipse - created Java class and package. Not recognized as part of the project
I installed m2e (1.7) plugin to use maven on eclipse Mars. 我安装了m2e(1.7)插件以在月食火星上使用maven。 Creating a new maven web-app project, I tried to add a new java class to src/main/resources folder.
创建一个新的Maven Web应用程序项目后,我尝试向src / main / resources文件夹添加一个新的Java类。 I simply created an Hello.java class in com.sample package.
我只是在com.sample包中创建了一个Hello.java类。
As you can see from the image below, the package is not shown as package visualization (It is shown as a folder path to the java class) and most important, opening the Hello.java class, editing the file with error, eclipse does not point out the error. 从下图可以看到,该包未显示为包可视化(它显示为java类的文件夹路径),最重要的是,打开Hello.java类,编辑带有错误的文件,eclipse不会指出错误。 Even the Hello.java file icon is different.
甚至Hello.java文件图标也不同。
How I can fix the problem? 我该如何解决该问题? thank you in advance.
先感谢您。
Normally, the Java source code should be in src/main/java source folder, not in src/main/resources like yours. 通常,Java源代码应位于src / main / java源文件夹中,而不是像您一样的src / main / resources中 。 To fix this: You should check if the src/main/java existed or not.
解决此问题的方法:您应该检查src / main / java是否存在。 You can do this by expanding the src/main folder at the bottom of the above image.
您可以通过展开上图底部的src / main文件夹来完成此操作。
If there is a java folder, you select and right click on the java folder --> Build Path --> Use as Source Folder . 如果有一个Java文件夹,则选择并右键单击 Java文件夹-> 构建路径 -> 用作源文件夹 。
If there is no src/main/java , you can create new one by right click on your project --> New --> Source Folder . 如果没有src / main / java ,则可以通过右键单击项目-> 新建 -> 源文件夹来创建新文件 。 Enter src/main/java
输入src / main / java
Then move your Hello.java to that folder. 然后将Hello.java移动到该文件夹。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.