简体   繁体   English

Grails 3.2.4,IntelliJ 2016.3.4中为脚本代码生成了一个综合类

[英]Grails 3.2.4, IntelliJ 2016.3.4 there is a synthetic class generated for script code

All my integration test had that error message after upgrading from Grails 2.5.1 to 3.2.4. 从Grails 2.5.1升级到3.2.4后,我所有的集成测试均显示该错误消息。 The upgrade includes moving the integration test from test/integration to src/integration-test. 升级包括将集成测试从测试/集成移动到src /集成测试。 IntelliJ 2016.3.4 would not recognize the classes as test classes. IntelliJ 2016.3.4无法将这些类识别为测试类。

我在1个文件中有2个程序包定义。

I was also facing the same issue, If you see at your class in package explorer, will find that there is class inside your test class with the same name. 我也面临着同样的问题,如果您在Package Explorer的类中看到,将发现测试类中有同名的类。

Copy code of your test class somewhere, Just delete your class(this way both the classes will be removed) and add it again and paste your code, my issue resolved by doing this. 将测试类的代码复制到某个地方,只需删除您的类(这样,两个类都将被删除),然后再次添加并粘贴您的代码,这样做可以解决我的问题。

In my case there was a groovy class with a method with excess closing brackets. 在我的情况下,有一个带有多余右括号的方法的常规类。 Ie: 即:

class A {

   public void methodA() {
   }
 }
}

   public void methodB() {
   }
}

After removing double "}" my problem was solved. 删除双“}”后,我的问题解决了。

Changing my imports fixed the problem. 更改进口商品可以解决此问题。

Old: 旧:

import grails.test.mixin.Mock
import grails.test.mixin.TestFor
import grails.test.mixin.integration.Integration
import spock.lang.Specification

New: 新:

import grails.test.mixin.Mock
import grails.test.mixin.integration.Integration
import grails.transaction.*
import spock.lang.*

In my situation, I had to rename the class. 在我的情况下,我不得不重命名该类。 I didn't have the class name duplicate in the test classes and I didn't have an excessive closing bracket. 我在测试班级中没有重复的班级名称,也没有过多的结束括号。

There's one thing that looks suspicious to me: 在我看来,有一件事可疑:

I have two groovy packages stored in app/src/main/groovy folder. 我在app / src / main / groovy文件夹中存储了两个groovy软件包。 When I navigate to them in the Project Tab for either the Android view or Project Files view, I see both packages, but they have different icons proceeding them. 当我在“项目”选项卡中导航至Android视图或“项目文件”视图时,我看到了两个软件包,但是它们的前进图标不同。 The first one has what looks like a java Class icon indicator and the second one has what looks like a groovy file indicator. 第一个具有看起来像Java类图标指示符,而第二个具有看起来像groovy文件指示符。 In the Android view, both of this files look like they are in the java folder. 在Android视图中,这两个文件看起来都位于java文件夹中。 It doesn't show me a groovy folder at all. 它根本没有显示groovy文件夹。 What I think may be happening is that android studio may be confused and think that I have the class duplicated in java and in groovy. 我认为可能正在发生的事情是android studio可能会感到困惑,并认为我在Java和groovy中重复了该类。 I think renaming the class got it unconfused. 我认为重命名该类会让他们感到困惑。 I can assure you, I don't have any java classes defined in this custom plugin project. 我可以向您保证,在此自定义插件项目中没有定义任何Java类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 犯罪集团部署用IntelliJ想法产生的Grails战争 - offending class deploying grails war generated with intellij idea Grails 3.2.4拒绝保存域实例:java.lang.IllegalArgumentException:object不是声明类的实例 - Grails 3.2.4 refuses to save domain instance: java.lang.IllegalArgumentException: object is not an instance of declaring class Grails生成的控制器中的新代码 - New code in Grails generated controller 将Grails生成的Java类包含在grails项目中 - Include Grails generated Java class into the grails project Grails 3.2.4:未调用自定义身份验证过滤器 - Grails 3.2.4 : custom authentication filter not called 带有 Intellij 的 Grails 3.2 无法扩展插件类 - Grails 3.2 with Intellij cannot extend plugin class 如何在IntelliJ中获取Grails的所有源代码 - How to get all source code for Grails in IntelliJ 从Hibernate 3 / Grails 2.2.4迁移到Hiberate 5 / Grails 3.2.4时,MappingException - MappingException when migrating from Hibernate 3 / Grails 2.2.4 to Hiberate 5 / Grails 3.2.4 如何使用Grails 3.2.4设置Cucumber以使用Grails进行测试? - How do I setup Cucumber with Grails 3.2.4 for Testing with Grails? Grails 渲染插件在 Grails3.2.4 中不起作用? - Grails rendering plugin does not work in Grails3.2.4?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM