如何让Eclipse解决使用Maven 2生成的类? [英] How do I get Eclipse to resolve classes generated with Maven 2?

查看:141
本文介绍了如何让Eclipse解决使用Maven 2生成的类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google协议缓冲区为我的项目生成一些Java类。使用Maven 2及其antrun插件,这些类在编译之前新生成,输出到目标/生成源,并在构建期间放在类路径上。因此,从POM构建项目是没有问题的。

I'm using Google Protocol Buffers to generate some Java classes for my project. Using Maven 2 and its "antrun" plugin, these classes are freshly generated before compile, output to target/generated-sources and put on the classpath during the build. So building the project from the POM is no problem.

然而,Eclipse不知道如何解决生成的类,因为它所在的文件夹似乎不在开发过程中放在IDE的classpath上。我正在使用m2eclipse,并为它管理依赖关系,所以我期望Maven能够照顾这个。

However, Eclipse doesn't know how to resolve the generated class, because the folder it's in doesn't seem to be on the IDE's classpath during development. I'm using m2eclipse and have it manage dependencies for me, so I had expected Maven to take care of this.

如何获得IDE支持(代码完成等) )对于生成的代码?

How can I get IDE support (code completion etc.) for the generated code?

推荐答案

在项目资源管理器中应该看到的是一个名为Maven Dependencies的容器,代替通常的参考图书馆。这意味着m2eclipse正在管理你的构建路径。

What you should see in your project explorer is a container named "Maven Dependencies" in place of the usual "Referenced libraries". This means m2eclipse is managing your build path.

在我的情况下,为了实现这一点,我检查了包含模块和 un 选中Skip处理资源时的Maven编译器插件在Project->属性的Maven部分。

In my case, to achieve this, I checked "Include Modules" and unchecked "Skip Maven compiler plugin when processing resources" on the "Maven" section of Project->Properties.

这篇关于如何让Eclipse解决使用Maven 2生成的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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