0

我正在使用播放!1.2.3

我正在尝试从 yaml 文件加载数据并使用 JPA 将其持久化,但出现异常

发生执行异常 RuntimeException:无法加载夹具 rss-sources.yml:模型 models.RSSSource 不受任何插件管理

有人可以提供建议吗?

堆栈跟踪是

Internal Server Error (500) for request GET /

Execution exception (In /app/controllers/Bootstrap.java around line 19)
RuntimeException occured : Cannot load fixture rss-sources.yml: Model models.RSSSource is      not managed by any plugin

play.exceptions.JavaExecutionException: Cannot load fixture rss-sources.yml: Model     models.RSSSource is not managed by any plugin
    at play.jobs.Job.call(Job.java:155)
at Invocation.Job(Play!)
Caused by: java.lang.RuntimeException: Cannot load fixture rss-sources.yml: Model models.RSSSource is not managed by any plugin
at play.test.Fixtures.loadModels(Fixtures.java:223)
at controllers.Bootstrap.doJob(Bootstrap.java:19)
at play.jobs.Job.doJobWithResult(Job.java:50)
at play.jobs.Job.call(Job.java:146)
... 1 more
Caused by: play.exceptions.UnexpectedException: Model models.RSSSource is not managed by any plugin
at play.db.Model$Manager.factoryFor(Model.java:57)
at play.test.Fixtures.resolveDependencies(Fixtures.java:386)
at play.test.Fixtures.loadModels(Fixtures.java:197)
... 4 more

我的模型类是:

package models;

import javax.persistence.*;

import play.db.jpa.*;
import play.data.validation.*;

import org.yaml.snakeyaml.Yaml;

/**
 * Class to describe a news url
 * contains url string and category
 * 
 * 
 *
 */

@Entity
@Table(name="RSSSourcesTable")
public class RSSSource
{
    //variable to old source
    @Required
    @Id
    private String source;

    //variables to hold urls for news category RSS feeds
    private String topNewsURL;
    private String worldNewsURL;
    private String ukNewsURL;
    private String usaNewsURL;
    private String sportsNewsURL;
    private String businessNewsURL;
    private String technologyNewsURL;


    public RSSSource(String source)
    {
        this.source = source;  
    }

    //getters and setters here
}

我的引导类是:

package controllers;

import play.jobs.Job;
import play.jobs.OnApplicationStart;
import play.jobs.OnApplicationStop;
import play.test.Fixtures;

@OnApplicationStart 
public class Bootstrap extends Job
{
/**
 * On start up this method loads the configuration that is set in the config loader, this contains the connection details for the 
 * RSS feed sources.
 * 
 */
     public void doJob()
    {
        System.out.println("Loading RSS sources from file: rss-sources.yml");
        Fixtures.loadModels("rss-sources.yml");
    }
}
4

1 回答 1

3

您的模型类应该扩展play.db.jpa.Model,或者在您的情况下,因为您使用的是自定义 ID play.db.jpa.GenericModel播放 JPA 文档)。IE

public class RSSSource

应该成为

public class RSSSource extends GenericModel

顺便说一句,您可能希望从 Play 1.2.3 更新到 1.2.5。

于 2013-04-15T11:54:39.530 回答