eclipse无法识别包

发布于 2024-10-02 01:07:55 字数 338 浏览 0 评论 0原文

(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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

忆离笙 2024-10-09 01:07:55

maven-archetype-webapp 默认情况下不会生成 src/main/java 文件夹,如果要在 Web 应用中添加 Java 源,则需要创建 >src/main/java 你自己。

创建此目录后,右键单击您的项目,然后使用 Maven >更新项目配置,它将被添加为源目录。然后您就可以添加来源。

最后一件事,要么使用 maven-eclipse-plugin ,要么使用 m2eclipse,而不是同时使用,它们是互斥的。

The maven-archetype-webapp does not generate a src/main/java folder by default and if you want to add Java sources in your webapp, you need to create src/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.

醉生梦死 2024-10-09 01:07:55

它应该有效。您可以在 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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文