gradle: @Entity symbol not found

问题: I've these dependencies into my build.gradle.kts: plugins { java checkstyle } repositories { gradlePluginPortal() } dependencies { compile("org.eclipse....

问题:

I've these dependencies into my build.gradle.kts:

plugins {
    java
    checkstyle
}

repositories {
    gradlePluginPortal()
}

dependencies {
    compile("org.eclipse.microprofile:microprofile:2.1")
    compile("org.hibernate.javax.persistence:hibernate-jpa-2.2-api:1.0.0.Beta2")
    compile("org.hibernate.ogm:hibernate-ogm-bom:5.4.1.Final")
    compile("org.hibernate.ogm:hibernate-ogm-mongodb:5.4.1.Final")
}

This is my code:

package main.java.io.espaidoc.persistence.domain;

@Entity
public class Reference {

    private String id;

    /**
     * @return the id
     */
    public String getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(String id) {
        this.id = id;
    }

}

Nevertheless, I'm getting this compilation error:

Reference.java:3: error: cannot find symbol
@Entity
 ^
  symbol: class Entity

回答1:

For JPA 2.2, you'd have to use:

compile("javax.persistence:javax.persistence-api:2.2")

, since mvnrepository.com says:

Note: This artifact was moved to:

javax.persistence » javax.persistence-api » ${jpa-api.version}

JPA 2 - 2.1 are still available under "org.hibernate.javax.persistence".

  • 发表于 2019-01-21 19:56
  • 阅读 ( 294 )
  • 分类:网络文章

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除