eclipse无法识别包
(HELIOS Eclipse,m2eclipse是从更新站点安装的)
我正在创建一个新的Web应用程序:File->New->Other->Maven->Maven Project,Next,Next,然后选择maven-archetype-webapp ,添加了 Group Id 和 Artifact Id。现在在新创建的项目中我想添加一个新的java包:右键单击,new ->包裹。插入包名称并单击完成。
我得到了一个新文件夹。 Eclipse 无法将其识别为包。
我应该怎么做才能让 Eclipse 将该文件夹识别为包?
许多蒂亚,
DHR
(HELIOS Eclipse, m2eclipse is installed from the update site)
I am creating a new web application: File->New->Other->Maven->Maven Project, Next, Next, then selected maven-archetype-webapp, added a Group Id and Artifact Id. Now in the newly created project I want to add a new java package: right click on , new -> package. Inserted package name and click on finish.
And I'm getting a new folder. Eclipse does not recognize this as a package.
What should I do to make Eclipse recognize that folder as a package?
Many tia,
DHR
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
maven-archetype-webapp
默认情况下不会生成src/main/java
文件夹,如果要在 Web 应用中添加 Java 源,则需要创建>src/main/java
你自己。创建此目录后,右键单击您的项目,然后使用 Maven >更新项目配置,它将被添加为源目录。然后您就可以添加来源。
最后一件事,要么使用 maven-eclipse-plugin ,要么使用 m2eclipse,而不是同时使用,它们是互斥的。
The
maven-archetype-webapp
does not generate asrc/main/java
folder by default and if you want to add Java sources in your webapp, you need to createsrc/main/java
yourself.Once this directory has been created, right-click on your project and then use Maven > Update Project Configuration and it will get added as source directory. Then you'll be able to add sources.
Last thing, either use the maven-eclipse-plugin or use m2eclipse, not both, they are mutually exclusive.
它应该有效。您可以在 eclipse 中将包含该包的文件夹标记为“源文件夹”,但这只是一种快速解决方案...
我通常使用 eclipse 而不使用 m2eclipse,并且运行
mvn eclipse:eclipse
来生成日食项目。也许你现在可以手动修复这个运行命令(从带有插件的 eclipse 或直接从 mvn)。It should work. You can mark the folder containing the package as "source folder" in eclipse, but only as a fast solution...
I usually work with eclipse wihout m2eclipse, and I run
mvn eclipse:eclipse
to generate the eclipse project. Maybe you can manually fix this running the command now (from eclipse with the plugin or from mvn directly).