IDEA给我的groovy类警告`class"MyClassTest"已经存在于"my.class.package"中.在运行测试时,它似乎也没有很好地保持课程更新.我将添加一个保证失败的断言,或者成功,直到稍后才会识别它(后来到目前为止似乎是随意的).鉴于我有maven测试正确传递和运行,我怀疑这只是一个IDEA配置问题
这是我的 pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xenoterracide</groupId>
<artifactId>rpf</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.1.9.RELEASE</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<goals>
<goal>addSources</goal>
<goal>addTestSources</goal>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>testGenerateStubs</goal>
<goal>testCompile</goal>
<goal>removeStubs</goal>
<goal>removeTestStubs</goal>
</goals>
</execution>
</executions>
<configuration>
<testSources>
<testSource>
<directory>${project.basedir}/src/test/groovy</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</testSource>
</testSources>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.8.0.DATAJPA-622-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<!--
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency> …Run Code Online (Sandbox Code Playgroud) 在IntelliJ(2016.2和之前的版本)中,我们将Groovy类标记为红色,并显示错误"class already exists".我认为我们可以排除原因是存根生成,因为它已停用.
可能它是在我们的星座中引起的:我们将已编译的groovy(和java)类包含在一个注册为依赖项的jar中.
依赖MyProduct.jar包含 com.mycompany.MyGroovyClass
我们的来源包含 com.mycompany.MyGroovyClass
如果依赖项已在Test-Scope中注册,则错误消失,在出现错误的所有其他范围内.
但是,在我们的结构中,我们必须将编译的类包含在编译范围内,因为我们希望避免每个开发人员需要编译所有类(我知道后台编译能力,但我们有一个星座可以防止这种情况发生.工作).
我们没有com.mycompany.MyJavaClass在源和MyProduct.jar中存在的错误.
关于我们如何解决这个问题的任何想法?