如果我有import org.hibernate.annotations.*
,IntelliJ似乎不会对我大喊大叫,但是如果我想使用@Type
和@Immutable
中的org.hibernate.annotations.Type
或org.hibernate.annotations.Immutable
批注,则IntelliJ会告诉我Cannot resolve symbol 'Immutable'
和Type
相同。
即使我显式导入所需的类,我仍然会收到错误。
我正在这样使用它:
import org.hibernate.annotations.Type; // Error: Cannot resolve symbol 'Type'
import org.hibernate.annotations.Immutable; // Error: Cannot resolve symbol 'Immutable'
import ...(other stuff)
@Entity
@Table(name = "T1")
@Immutable // Error: Cannot resolve symbol 'Immutable'
public class Info {
@Column(name = "A_DATE")
@Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime") // Error: cannot resolve symbol 'Type'
private DateTime myDate;
...(other stuff)
}
此外,我的
build.gradle
文件具有以下依赖性:dependencies {
compile "org.hibernate:hibernate-core:4.2.3.Final"
compile "org.hibernate:hibernate-jpamodelgen:1.3.0.Final"
compile 'org.hibernate:hibernate-entitymanager:4.2.3.Final'
...(other stuff)
}
我已经使用Gradle清理并重建了项目。有任何想法吗?
最佳答案
在build.gradle中添加以下依赖项。这样可以解决问题。
'net.jcip:jcip-annotations:1.0'
关于java - 导入org.hibernate.annotations.Immutable/Type时出错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36349407/