我正在我的应用程序中构建一个Ebean服务器。这是代码:
public Result refreshDataFromProduction() {
if (hasCorrectAccess(RoleType.BAMANAGER) != true && hasCorrectAccess(RoleType.SEMANAGER) != true
&& hasCorrectAccess(RoleType.ADMIN) != true) {
return ACCESS_DENIED;
} else {
// Get the eEbean server...
// Get the application.conf...
String serverEnvironment = "test";
String getValue = "";
Configuration appConfig = Configuration.root();
DataSourceConfig dataconfig = new DataSourceConfig();
getValue = Messages.get("db." + serverEnvironment + ".url");
dataconfig.setUrl(getValue);
getValue = Messages.get("db." + serverEnvironment + ".driver");
dataconfig.setDriver(getValue);
getValue = Messages.get("db." + serverEnvironment + ".username");
dataconfig.setUsername(getValue);
getValue = Messages.get("db." + serverEnvironment + ".password");
dataconfig.setPassword(getValue);
// Create the server config...
ServerConfig c = new ServerConfig();
c.setName(serverEnvironment);
c.setDdlGenerate(false);
c.setDdlRun(false);
c.setDefaultServer(true);
c.setRegister(true);
c.setDataSourceConfig(dataconfig);
// Add all Models here...
c.addClass(User.class);
EbeanServer server = EbeanServerFactory.create(c);
server.save(server);
return ok(genericsuccess.render());
}
}
此行发生错误:
EbeanServer server = EbeanServerFactory.create(c);
以下是完整错误:
play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[RuntimeException: Error reading annotations for models.User]]
at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:293)
at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:220)
at play.api.GlobalSettings$class.onError(GlobalSettings.scala:160)
at play.core.j.JavaGlobalSettingsAdapter.play$core$j$JavaGlobalSettingsAdapter$$super$onError(JavaGlobalSettingsAdapter.scala:35)
at play.core.j.JavaGlobalSettingsAdapter$$anonfun$onError$2.apply(JavaGlobalSettingsAdapter.scala:35)
at play.core.j.JavaGlobalSettingsAdapter$$anonfun$onError$2.apply(JavaGlobalSettingsAdapter.scala:35)
at scala.Option.getOrElse(Option.scala:121)
at play.core.j.JavaGlobalSettingsAdapter.onError(JavaGlobalSettingsAdapter.scala:35)
at play.api.http.GlobalSettingsHttpErrorHandler.onServerError(HttpErrorHandler.scala:100)
at play.core.server.netty.PlayRequestHandler$$anonfun$2$$anonfun$apply$1.applyOrElse(PlayRequestHandler.scala:100)
Caused by: java.lang.RuntimeException: Error reading annotations for models.User
at com.avaje.ebeaninternal.server.deploy.parse.ReadAnnotations.readAssociations(ReadAnnotations.java:85)
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readDeployAssociations(BeanDescriptorManager.java:1076)
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readEntityDeploymentAssociations(BeanDescriptorManager.java:580)
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.deploy(BeanDescriptorManager.java:301)
at com.avaje.ebeaninternal.server.core.InternalConfiguration.<init>(InternalConfiguration.java:130)
at com.avaje.ebeaninternal.server.core.DefaultContainer.createServer(DefaultContainer.java:122)
at com.avaje.ebeaninternal.server.core.DefaultContainer.createServer(DefaultContainer.java:42)
at com.avaje.ebean.EbeanServerFactory.createInternal(EbeanServerFactory.java:108)
at com.avaje.ebean.EbeanServerFactory.create(EbeanServerFactory.java:67)
at jobs.Jobs.refreshDataFromProduction(Jobs.java:1533)
Caused by: java.lang.RuntimeException: Error with association to [class models.LinkedAccount] from [models.User.linkedAccounts]. Is class models.LinkedAccount registered?
at com.avaje.ebeaninternal.server.deploy.parse.AnnotationAssocManys.readToOne(AnnotationAssocManys.java:307)
at com.avaje.ebeaninternal.server.deploy.parse.AnnotationAssocManys.read(AnnotationAssocManys.java:57)
at com.avaje.ebeaninternal.server.deploy.parse.AnnotationAssocManys.parse(AnnotationAssocManys.java:48)
at com.avaje.ebeaninternal.server.deploy.parse.ReadAnnotations.readAssociations(ReadAnnotations.java:76)
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readDeployAssociations(BeanDescriptorManager.java:1076)
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readEntityDeploymentAssociations(BeanDescriptorManager.java:580)
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.deploy(BeanDescriptorManager.java:301)
at com.avaje.ebeaninternal.server.core.InternalConfiguration.<init>(InternalConfiguration.java:130)
at com.avaje.ebeaninternal.server.core.DefaultContainer.createServer(DefaultContainer.java:122)
at com.avaje.ebeaninternal.server.core.DefaultContainer.createServer(DefaultContainer.java:42)
我发现了一些帖子,但那些似乎没有帮助我:
Error reading annotations play framework 2.2
How solve error reading annotations in play framework 2
以下是我正在使用的课程:
@Entity
public class User extends Model {
@Id
public Long id;
@Constraints.Required
@Formats.NonEmpty
@Column(unique = true)
private String email;
@Constraints.Required
@Formats.NonEmpty
@Column(unique = true)
public String fullname;
@OneToMany(cascade = CascadeType.ALL)
public List<LinkedAccount> linkedAccounts;
...
}
@Entity
public class LinkedAccount extends AppModel {
private static final long serialVersionUID = 1L;
@Id
public Long id;
@ManyToOne
@JoinColumn(name = "user", insertable = false, updatable = false)
public User user;
public String providerUserId;
public String providerKey;
public Long userId;
public String email;
...
}
我猜它与@OneToMany
和@ManyToOne
引用有关,但不确定如何纠正。