【问题标题】:Error importing org.hibernate.annotations.Immutable/Type?导入 org.hibernate.annotations.Immutable/Type 时出错?
【发布时间】:2016-07-20 20:26:24
【问题描述】:

如果我有import org.hibernate.annotations.*,IntelliJ 似乎不会对我大喊大叫,但如果我想使用来自org.hibernate.annotations.Typeorg.hibernate.annotations.Immutable@Type@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 清理并重建了项目。有什么想法吗?

【问题讨论】:

    标签: java hibernate intellij-idea gradle annotations


    【解决方案1】:

    在 build.gradle 中添加以下依赖项。这应该可以解决问题。

    'net.jcip:jcip-annotations:1.0'
    

    【讨论】:

    • 嗯,似乎没有解决问题,不幸的是:(
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-08-07
    • 2017-05-05
    • 2012-10-28
    • 2016-09-01
    • 2019-01-16
    • 2018-03-19
    • 2017-09-12
    相关资源
    最近更新 更多