我遇到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
的测试中时,我收到了上述消息。请参阅附图:
答案 0 :(得分:0)
我通过文件->使缓存无效/重新启动来解决ItellijIDEA中的类似问题。