【发布时间】:2018-01-12 11:45:12
【问题描述】:
我在使用 IntelliJ 时遇到问题,它在我的许多 groovy 测试文件中显示以下错误:
'save' in 'org.springframework.data.jpa.repository.JpaRepository<testmodule.TestEntity,java.lang.Long>' cannot be applied to '(testmodule.TestEntity)' less... (Ctrl+F1) This inspection reports assignments with incompatible types
我可以使用以下类重现该问题:
实体:
package testmodule;
public class TestEntity {
private Long id;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
存储库:
package testmodule;
import org.springframework.data.jpa.repository.JpaRepository;
public interface TestEntityRepository extends JpaRepository<TestEntity, Long> {
}
spock 测试:
package testmodule
import org.springframework.beans.factory.annotation.Autowired
class TestEntityRepositoryTest {
@Autowired
TestEntityRepository testEntityRepository
def "should save testEntity"() {
given:
final testEntity = new TestEntity()
when:
final saved = testEntityRepository.save(testEntity)
}
}
当我在测试中将鼠标悬停在testEntity 上时,我收到了上述消息。请看附图:
【问题讨论】:
-
您使用的是什么版本的 IntelliJ IDEA?我复制了与您展示的相同的课程,并且 IDEA 2017.2.6 没有抱怨此类警告。
-
@SzymonStepniak 我使用的是 2017.3.2 Ultimate Edition。
-
我报告了一个问题,你可以投票/关注:IDEA-184877
-
谢谢@Andrey!所以这是从以前版本的 Intellij 的回归?如何在 Youtrack 中为某个问题投票?
-
看起来像回归。如果您不熟悉 YouTrack,请参阅 intellij-support.jetbrains.com/hc/en-us/articles/207241135。
标签: java spring intellij-idea groovy spring-data-jpa