java - 使用ebean通过play框架从mysql获取数据

标签 java playframework playframework-2.0 ebean

我正在尝试使用 Play! 从我的 mysql 服务器获取数据。我的方法是这样的:

  1. /application.conf中:

    db.default.driver=com.mysql.jdbc.Driver    
    db.default.url="jdbc:mysql://localhost:3306/CED?characterEncoding=UTF-8"  
    db.default.user="root"  
    db.default.password="root"  
    ebean.default="models.*"
    
  2. /models/Budget.java:

    package models;
    
    //imports
    
    @Entity
    
    public class Budget extends Model {  
    @Id  
    public String id;
    
    @Constraints.Required
    public String hauptkategorie;
    
    public static Model.Finder<String,Budget> find = new Model.Finder<String,Budget>(String.class, Budget.class);
    
    public static Map<String,String> options() {
        LinkedHashMap<String,String> options = new LinkedHashMap<String,String>();
        for(Budget c: Budget.find.orderBy("id").findList()) {
            options.put(c.id, c.hauptkategorie);
        }
        System.out.println(options);
        return options;
    }
    }
    

我在 CED 数据库中有一个表,名为预算,有 2 列 id,hauptkategorie。当我运行服务器时,我收到此错误数据库“默认”需要进化!并尝试应用创建表的sql脚本。但是,我想要预算的是从数据库中获取数据。哪里可能是配置问题或缺少部分?

最佳答案

您必须在 application.conf 中取消注释此属性

   # Evolutions
   # ~~~~~
   # You can disable evolutions if needed
   evolutionplugin=disabled

关于java - 使用ebean通过play框架从mysql获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15139401/

相关文章:

java - Play Framework MVC 邮件程序

java - ( Play 2.1.3) @select 返回(String, String) 对

json - 如何从 Play 应用程序中的 play.mvc.Result 对象中提取结果内容?

java - LinkedList中Iterator的remove()方法

java - 如何通过Selenium阻止chrome中的弹出窗口

java - 无法将 JPA 依赖项添加到 spring-boot 项目中

java - 如何在 Windows 上的 eclipse 中运行 nutch 1.9?

java - 为什么作为路由参数的映射类型不匹配?

scala - 可选的 Json 正文解析器

json - Play ScalaJSON Reads[T] 解析 ValidationError(error.path.missing,WrappedArray())