我已经开始学习Play框架,遵循Java指南(教程“ZenTasks”)。一切顺利,直到我发现此错误:Error reading annotations for models.Task
package models;
import java.util.*;
import javax.persistence.*;
import play.db.ebean.*;
@Entity
public class Task extends Model {
@Id
public Long id;
public String title;
public boolean done = false;
public Date dueDate;
@ManyToOne
public User assignedTo;
public String folder;
@ManyToOne
public Project project;
public static Model.Finder<Long,Task> find = new Model.Finder(Long.class, Task.class);
public static List<Task> findTodoInvolving(String user) {
return find.fetch("project").where()
.eq("done", false)
.eq("project.members.email", user)
.findList();
}
public static Task create(Task task, Long project, String folder) {
task.project = Project.find.ref(project);
task.folder = folder;
task.save();
return task;
}
}
@6hgmo097m - Internal server error, for (GET) [/] ->
play.api.UnexpectedException: Unexpected exception[RuntimeException: Error reading annotations for models.Task]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:148) ~[play_2.10.jar:2.2.1]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:112) ~[play_2.10.jar:2.2.1]
at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:112) ~[play_2.10.jar:2.2.1]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:110) ~[play_2.10.jar:2.2.1]
at scala.util.Success.flatMap(Try.scala:200) ~[scala-library.jar:na]
Caused by: java.lang.RuntimeException: Error reading annotations for models.Task
at com.avaje.ebeaninternal.server.deploy.parse.ReadAnnotations.readAssociations(ReadAnnotations.java:54) ~[avaje-ebeanorm.jar:na]
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readDeployAssociations(BeanDescriptorManager.java:1048) ~[avaje-ebeanorm.jar:na]
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readEntityDeploymentAssociations(BeanDescriptorManager.java:547) ~[avaje-ebeanorm.jar:na]
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.deploy(BeanDescriptorManager.java:237) ~[avaje-ebeanorm.jar:na]
at com.avaje.ebeaninternal.server.core.InternalConfiguration.<init>(InternalConfiguration.java:114) ~[avaje-ebeanorm.jar:na]
at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:204) ~[avaje-ebeanorm.jar:na]
Caused by: java.lang.RuntimeException: Error with association to [class models.Project] from [models.Task.project]. Is class models.Project registered?
at com.avaje.ebeaninternal.server.deploy.parse.AnnotationAssocOnes.readManyToOne(AnnotationAssocOnes.java:165) ~[avaje-ebeanorm.jar:na]
at com.avaje.ebeaninternal.server.deploy.parse.AnnotationAssocOnes.readAssocOne(AnnotationAssocOnes.java:63) ~[avaje-ebeanorm.jar:na]
at com.avaje.ebeaninternal.server.deploy.parse.AnnotationAssocOnes.parse(AnnotationAssocOnes.java:54) ~[avaje-ebeanorm.jar:na]
at com.avaje.ebeaninternal.server.deploy.parse.ReadAnnotations.readAssociations(ReadAnnotations.java:45) ~[avaje-ebeanorm.jar:na]
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readDeployAssociations(BeanDescriptorManager.java:1048) ~[avaje-ebeanorm.jar:na]
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readEntityDeploymentAssociations(BeanDescriptorManager.java:547) ~[avaje-ebeanorm.jar:na]
答案 0 :(得分:24)
有同样的错误,(对我而言)是由我的@ManyToOne
相关类没有标记@Entity
注释引起的(在您的情况下检查User
和{{1} })。还要确保这些课程。引用回Project
包含Task
引用。