通过将多个模块的Maven 2项目导入Eclipse工作区而出现问题 [英] Problems by import of a multiple modules maven 2 project into eclipse workspace

查看:276
本文介绍了通过将多个模块的Maven 2项目导入Eclipse工作区而出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人遇到过与我相同的问题并且可以帮助我. 我有一个包含6个模块的Maven项目.一些模块相互依赖.该项目是用Java编写的,可构建为jars,wars和aar.我一直在尝试使用m2eclipse插件将其导入Eclipse.在项目建立之前,它似乎工作正常.在构建过程中,我收到数百个错误,抱怨缺少生成的Java文件.我发现eclipse无法识别某些生成的软件包应被解释为源代码.我真的不知道该怎么办,因为我已经花了很多时间尝试解决此问题.该项目在命令行中运行良好.我的目标是在Tomcat服务器上调试整个项目,这就是为什么我要使用eclipse的原因,因为它与Tomcat的集成度很好.

I was wondering if someone has experienced the same problem as me and can help me. I have a maven project which contains 6 modules. Some of modules are depending on each other. The project is written in Java and builds to jars, wars and aar. I've been trying to import it to Eclipse with the m2eclipse plug-in. It seems to work fine until the project builds. During the build process I get hundreds of errors complaining about missing Java files which are generated. As I found out eclipse can't recognize that some of generated packages should be interpreted as source code. I don't realy know what to do with it as I spent a lot of time already trying to solve this issue. The project is building fine with command line. My target is to debug the whole project on Tomcat server that's why I want to use eclipse as it has a pretty good integration with Tomcat.

我们将不胜感激.

谢谢!

推荐答案

为什么未将生成的源文件夹添加到常见问题解答的类路径条目中:

用于生成源代码的Maven插件 来自资源或其他来源的代码 可以注册其他源文件夹 在构建期间访问Maven项目. 通常,此类插件必须绑定到 流程资源(或 流程测试资源)构建阶段 (例如jaxb,modello或xdoclet 插件).这意味着要获得那些 用于生成源的源文件夹, 我们必须运行相应的Maven 构建阶段.

Maven plugins used to generate source code from resources or other sources can register additional source folders to Maven project during the build. Usually such plugins are bound to process-resources (or process-test-resources) build phase (for example jaxb, modello or xdoclet plugins). This means that to get those source folders for generated sources, we have to run corresponding Maven build phase.

并非所有使用生成的项目 来源,因此出于性能方面的考虑, m2eclipse没有运行任何Maven目标 默认情况下,导入项目时.这个可以 可以在Maven设置中进行更改 "窗口> 首选项... > Maven > 要在项目导入时运行的目标"(例如 您可以指定过程资源" 构建阶段或特定的插件 该字段).

Not all projects using generated sources, so for performance reasons, m2eclipse does not run any Maven goals by default on project import. This can be changed in the Maven settings in "Window > Preferences... > Maven > Goals to run on project import" (e.g. you can specify "process-resources" build phase or specific plugins in that field).

或者,您也可以运行" Maven > 更新项目配置"操作 从项目弹出菜单中 配置为运行流程资源" 默认情况下,也可以更改 在同一首选项页面上.

Alternatively you can run "Maven > Update project configuration" action from the project popup menu, which is configured to run "process-resources" by default and it can be also changed on the same preference page.

因此,要么将源生成过程绑定到的目标添加到要在导入时运行的目标列表,要么通过运行maven并更新项目配置来生成源.

So either add the goal to which the source generation process is bound to the list of goals to run on import or generate sources by running maven and update the project configuration.

这篇关于通过将多个模块的Maven 2项目导入Eclipse工作区而出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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