Eclipse Maven工作区解析看不到生成的类 [英] Eclipse Maven Workspace Resolution not seeing Generated Classes

查看:64
本文介绍了Eclipse Maven工作区解析看不到生成的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个月食的Maven项目,一个罐子和一个战争.战争对jar的依赖性很大,可以通过工作空间解析来解决.

I have two maven projects in eclipse, a jar and a war. The war has a dependency on the jar, which is resolved through workspace resolution.

问题在于jar已生成类,这些类通过build-helper-maven-plugin添加到jar中.但是这些类在战争项目中没有得到适当解决.例如:它自动完成该类,但一直说找不到它.更重要的是,在通过日食运行glassfish时,我得到了一个在这些类中找不到的类.

The problem is that the jar has generated classes, which are added to the jar through build-helper-maven-plugin. But these classes aren't being properly resolved in the war project. For example: It auto-completes the class but keeps saying it can't be found. More importantly, when running glassfish through eclipse, I get a class not found for these classes.

如果禁用工作空间分辨率,则一切正常,但希望使用工作空间分辨率.有什么想法吗?

If I disable workspace resolution everything works fine, but I hope to use workspace resolution. Any ideas?

文件夹结构.下部图像中的Maven工作区已解决的持久性项目位于Maven Dependencies文件夹中,从本质上讲,您可以看到该文件夹​​的顶部和底部.

Folder structure. The maven workspace resolved persistence project in the lower image is in the Maven Dependencies folder, essentially your seeing the top and bottom of the folder.

推荐答案

如果我是对的,则使用IDK,但是您在谈论的是Eclipse问题-它不能看到"生成的类吗?

IDK if I am correct, but you are talking about Eclipse problems - it does not "see" generated classes right?

要修复此问题,必须将生成的源目录添加到Eclipse的构建路径中,它应该可以解决您的问题.

To fix it, you have to add generated sources directory to the eclipse's build path and it should fix your problem.

  1. 右键单击已生成类-> buildPath-> conf的项目 构建路径
  2. 在源"选项卡中-单击添加文件夹"
  3. 选择构建助手生成Java文件的目录.
  1. Right click on project that has generated classes->buildPath->conf buildpath
  2. In source tab - click add folder
  3. Select the directory where build helper generates java files.

生成的类将作为Eclipse项目层次结构中的其他源文件夹出现,瞧,Eclipse可以在相同条件下自动完成并解析生成的类,就像您在同一项目中手工编写的任何其他类上一样.

Generated classes will apear as additional source folder in Eclipse's project hierarchy and voila, Eclipse can autocomplete and resolve generated classes now on the same conditionstha any it would on any other class written by you in the same project by hand.

这篇关于Eclipse Maven工作区解析看不到生成的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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