“类已经存在"; Groovy类上的IntelliJ错误 [英] "Class already exists" error in IntelliJ on Groovy class

查看:148
本文介绍了“类已经存在"; Groovy类上的IntelliJ错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在IntelliJ(2016.2及更早版本)中,我们将Groovy类标记为红色,并显示错误类已存在". 我认为我们可以排除原因是存根生成,因为它已被停用.

in IntelliJ (2016.2 and previous) we have our Groovy classes marked red with the error "class already exists". I think we can exclude that the cause is the stub-generation, as this is deactivated.

可能是在我们的星座中引起的:我们在一个注册为依赖项的jar中包含了已编译的groovy(和Java)类.

Probably it's caused in our constellation: We have included our compiled groovy (and java) classes in a jar that is registered as dependency.

依赖项MyProduct.jar包含com.mycompany.MyGroovyClass

Dependency MyProduct.jar contains com.mycompany.MyGroovyClass

我们的来源包含com.mycompany.MyGroovyClass

如果依赖项已在Test-Scope中注册,则错误消失,在所有其他范围中,错误都会出现.

The error disappears if the dependency is registered with Test-Scope, in all other scopes the error appears.

但是,在我们的结构中,我们有点必须将编译后的类包含在编译范围内,因为我们希望避免每个开发人员都需要编译所有类(我知道后台编译的能力,但我们的星座阻止了此操作.

However, in our structure we kinda have to include the compiled classes in a compile scope, as we want to avoid that each developer needs to compile all classes (I know about the compile in background ability, but we have a constellation that prevents this from working).

我们在com.mycompany.MyJavaClass中没有错误,该错误在源代码和MyProduct.jar中也都存在.

We have no errors in com.mycompany.MyJavaClass which exists as well in source and in MyProduct.jar.

关于如何解决这个问题的任何想法?

Any ideas on how we can solve this?

推荐答案

我们一直在遇到同样的问题,似乎IntelliJ注册了Java类,但也注册了Groovy类,因此它正在显示该消息(顺便说一句,我们正在使用Maven项目).

We've been suffering the same issue, it seems to be that IntelliJ registers the Java class, but also the Groovy class, and because of that it is showing that message (BTW, we are using a Maven Project).

因此,最终我们转到了目标文件夹->右键单击->将目录标记为->已排除.然后,此设置将保存在IML文件中,并且不会再次发生.

So we ended up by going to the target folder -> right click -> Mark Directory As -> Excluded. Then, this setting will be saved on the IML file, and it won't happen again.

希望它也对您有用! 干杯

Hope it works for your as well! Cheers

这篇关于“类已经存在"; Groovy类上的IntelliJ错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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