本文介绍了AndroidStudio / gradle找不到javax.persistence包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试执行以下教程时:
使用Android Studio创建了一个Android Studio项目并添加了CheckIn.java类,其中包含以下内容:
import java.util.Date;
import com.google.appengine.api.datastore.Key;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class CheckIn {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private java.security.Key key;
私人字符串placeId;
私人字符串userEmail;
私人日期checkinDate;
public java.security.Key getKey(){
return key;
}
public String getPlaceId(){
return placeId;
}
public void setPlaceId(String placeId){
this.placeId = placeId;
}
public String getUserEmail(){
return userEmail;
}
public void setUserEmail(String userEmail){
this.userEmail = userEmail;
}
public Date getCheckinDate(){
return checkinDate;
}
public void setCheckinDate(Date date){
checkinDate = date;
}
}
但是,当我尝试在Android Studion / gradle项目中构建项目时,出现以下错误:
错误:(6 ,25)错误:程序包javax.persistence不存在
错误:(7,25)错误:程序包javax.persistence不存在
错误:(8,25)错误:程序包javax.persistence不存在
错误:(9,25)错误:程序包javax.persistence不存在
错误:(11,2)错误:找不到符号类实体
错误:(14,6 )错误:无法找到符号类Id
错误:(15,6)错误:无法找到符号类GeneratedValue
错误:(6,25)错误:程序包javax.persistence不存在
错误:(7,25)错误:程序包javax.persistence不存在
错误:(8,25)错误:程序包javax.persistence不存在
错误:(9,25)错误:程序包javax.persistence不存在
错误:(11,2)错误:找不到符号类实体
错误:(14,6)错误:无法找到s ymbol class Id
错误:(15,6)错误:无法找到符号类GeneratedValue
解决方案
当我添加时,它得到了修复:
编译组:'javax.persistence',名称:'persistence-api',版本:'1.0'
指向我的gradle依赖关系。如所述。
While attempting to do the following tutorial :
using Android Studio, I created an Android Studio project and added the CheckIn.java class with the following contents :
import java.util.Date;
import com.google.appengine.api.datastore.Key;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class CheckIn {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private java.security.Key key;
private String placeId;
private String userEmail;
private Date checkinDate;
public java.security.Key getKey() {
return key;
}
public String getPlaceId() {
return placeId;
}
public void setPlaceId(String placeId) {
this.placeId = placeId;
}
public String getUserEmail() {
return userEmail;
}
public void setUserEmail(String userEmail) {
this.userEmail = userEmail;
}
public Date getCheckinDate() {
return checkinDate;
}
public void setCheckinDate(Date date) {
checkinDate = date;
}
}
But when I try to build the project in my Android Studion / gradle project, I get the following errors :
Error:(6, 25) error: package javax.persistence does not exist
Error:(7, 25) error: package javax.persistence does not exist
Error:(8, 25) error: package javax.persistence does not exist
Error:(9, 25) error: package javax.persistence does not exist
Error:(11, 2) error: cannot find symbol class Entity
Error:(14, 6) error: cannot find symbol class Id
Error:(15, 6) error: cannot find symbol class GeneratedValue
Error:(6, 25) error: package javax.persistence does not exist
Error:(7, 25) error: package javax.persistence does not exist
Error:(8, 25) error: package javax.persistence does not exist
Error:(9, 25) error: package javax.persistence does not exist
Error:(11, 2) error: cannot find symbol class Entity
Error:(14, 6) error: cannot find symbol class Id
Error:(15, 6) error: cannot find symbol class GeneratedValue
解决方案
This got fixed when I added:
compile group: 'javax.persistence', name: 'persistence-api', version: '1.0'
to my gradle dependencies. As described here.
这篇关于AndroidStudio / gradle找不到javax.persistence包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!