java - 在 play.db.ebean.EbeanPlugin 中找不到合适的构造函数,如何解决此问题?

标签 java playframework playframework-2.0 guice ebean

出现以下错误:

ConfigurationException: Guice configuration errors:

1) Could not find a suitable constructor in play.db.ebean.EbeanPlugin. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private. at play.db.ebean.EbeanPlugin.class(EbeanPlugin.java:23) while locating play.db.ebean.EbeanPlugin

1 error

任何人都可以帮我解决这个问题吗?我是游戏框架的新手,无法真正解决此类问题。

package models;

import java.util.List;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

import play.db.ebean.Model;


@MappedSuperclass
public class Bar extends Model {

    @Id
    public String id;

    public String name;
}

插件.sbt

    // The Play plugin
    addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.2")

    // Web plugins
    addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
    addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.0.6")
    addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.3")
    addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7")
    addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0")
    addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0")
    addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.0.0")

    // Play enhancer - this automatically generates getters/setters for public fields
    // and rewrites accessors of these fields to use the getters/setters. Remove this
    // plugin if you prefer not to have this feature, or disable on a per project
    // basis using disablePlugins(PlayEnhancer) in your build.sbt
    addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0")

    // Play Ebean support, to enable, uncomment this line, and enable in your build.sbt using
    // enablePlugins(SbtEbean). Note, uncommenting this line will automatically bring in
    // Play enhancer, regardless of whether the line above is commented out or not.
    addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "1.0.0")

最佳答案

您的类没有一个(且只有一个)用 @Inject 注释的构造函数或非私有(private)的零参数构造函数

尝试添加一个非私有(private)的零参数构造函数,例如

public Bar() {}

关于java - 在 play.db.ebean.EbeanPlugin 中找不到合适的构造函数,如何解决此问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31414923/

相关文章:

javascript - 如何将值从 Javascript 传递到 Wicket?

java - 将所有 HashMap 键小写

java - Java中有 'logic programming'的元素吗?

error-handling - 如何使用依赖注入(inject) Play Framework 2.4 处理 "Action not found"

scala - 需要引用基于开源 Play Framework 的 Scala 应用程序

java - @RequestBody 没有将 JSON 映射到 Java 对象 - Spring Boot

java - 未处理的异常类型NoSuchFieldException(java反射)

java - [ValidationException : HV000041: Call to TraversableResolver. isReachable() 抛出异常。]

json - 在 Play Framework 2.1.x 中将 Scala 案例类漂亮地打印到 JSON 的最简单方法是什么?

java - 玩! 2.0 覆盖 "Invalid Value"消息