我开始学习Play框架,按照Java指南(教程“ZenTasks”)进行。一切都很顺利,直到我遇到这个错误:读取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]