Playframework 形式在起作用!2.5

Playframework 形式在起作用!2.5,playframework,playframework-2.0,ebean,Playframework,Playframework 2.0,Ebean,我有一个剧本!2.2我升级到2.5的项目。但是,升级后我的数据库出现了问题,看起来是配置错误或遗漏。 看起来更改没有保存,表单也不起作用 我确实在application.conf中声明了ebeans指令: ebean.default= ["models.*"] 然后在plugins.sbt和build.sbt中加载模块。 作为我的代码示例,我有一个设备: @Entity public class Device extends Model { @Id public Long i

我有一个剧本!2.2我升级到2.5的项目。但是,升级后我的数据库出现了问题,看起来是配置错误或遗漏。 看起来更改没有保存,表单也不起作用

我确实在application.conf中声明了ebeans指令:

ebean.default= ["models.*"]
然后在plugins.sbt和build.sbt中加载模块。 作为我的代码示例,我有一个设备:

@Entity
public class Device extends Model {

    @Id
    public Long id;

    @Constraints.Required
    public String name;

    @Constraints.Required
    public String ipAddress;

    @Constraints.Required
    public String uniqueId;

    @OneToMany(mappedBy="device")
    public List<Sensor> sensors = new ArrayList<>();

    @OneToMany(mappedBy="device")
    public List<Action> actions = new ArrayList<>();

    @OneToOne
    public LogItem latestError;

    @Version
    public Timestamp lastUpdate;

    public boolean debugMode;

    public boolean statusLed;

    public static Finder<Long, Device> find = new Finder<Long, Device>(
            Long.class, Device.class
    );

    public List<ValidationError> validate() {
        /*
        List<ValidationError> errors = new ArrayList<ValidationError>();
        if (User.byEmail(email) != null) {
            errors.add(new ValidationError("email", "This e-mail is already registered."));
        }
        return errors.isEmpty() ? null : errors;
        */
        return null;
    }
}
我还有一个预填充的记录,当我编辑它时,表单字段都是空的。但是,调试显示数据在那里,并且“传感器”也会出现,它是从对象本身生成的列表


所以我的配置一定有问题!2.5,但我不知道是什么。

这似乎是一个缓存问题。使用:

activator clean
activator clean-files
重建项目解决了这个问题

@(deviceForm: Form[Device], device: Device)

    @if(deviceForm.hasGlobalErrors) {
        <ul>
        @deviceForm.globalErrors.foreach { error =>
            <li>error.message</li>
        }
        </ul>
    }


    @main("Edit a device") {

        @if(deviceForm("id").value == "" || deviceForm("id").value == null) {
            <h2>Add the device</h2>
        } else {
            <h2>Update the device</h2>
        }

        @helper.form(action = routes.Devices.update()) {

            @helper.inputText(
                deviceForm("name"),
                '_label -> "Device name"
            )

            @helper.inputText(
                deviceForm("ipAddress"),
                '_label -> "IP Address"
            )

            @helper.inputText(
                deviceForm("uniqueId"),
                '_label -> "Unique ID"
            )

            @helper.checkbox(
                deviceForm("statusLed"),
                '_label -> "Status light"
            )

            @helper.checkbox(
                deviceForm("debugMode"),
                '_label -> "Debug mode"
            )

            @if(device != null){
            <div>Sensors:</div>
            <div>
            <table class="adminTable">
            @for(sensor <- device.sensors) {
              <tr>
              <td>@sensor.value</td>
              <td><a href="@routes.Sensors.edit(sensor.id)">edit<a/> | <a href="@routes.Sensors.delete(sensor.id)">delete</a></td>
              </tr>
            }
            </table>
            </div>
            }
            @if(deviceForm("id").value != "" && deviceForm("id").value != null) { <div>Last updated: @device.lastUpdate.format("dd MMM yy - HH:mm:ss")</div> }
            <div>
                <input type="hidden" name="id" value="@deviceForm("id").value">
                <input type="submit" value="Submit">
            </div>
        }

        <a href="@routes.Devices.index()">Cancel</a>
    }
[error] p.c.s.n.PlayDefaultUpstreamHandler - Cannot invoke the action
java.lang.IllegalStateException: JSR-303 validated property 'name' does not have a corresponding accessor for data binding - check your DataBinder's configuration (bean property versus direct field access)
    at play.data.Form.bind(Form.java:372) ~[play-java_2.11-2.4.4.jar:2.4.4]
    at play.data.Form.bindFromRequest(Form.java:222) ~[play-java_2.11-2.4.4.jar:2.4.4]
    at controllers.Devices.update(Devices.java:44) ~[classes/:na]
    at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$4$$anonfun$apply$4.apply(Routes.scala:558) ~[classes/:na]
    at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$4$$anonfun$apply$4.apply(Routes.scala:558) ~[classes/:na]
    at play.core.routing.HandlerInvokerFactory$$anon$4.resultCall(HandlerInvoker.scala:136) ~[play_2.11-2.4.4.jar:2.4.4]
    at play.core.routing.HandlerInvokerFactory$JavaActionInvokerFactory$$anon$14$$anon$3$$anon$1.invocation(HandlerInvoker.scala:127) ~[play_2.11-2.4.4.jar:2.4.4]
    at play.core.j.JavaAction$$anon$1.call(JavaAction.scala:70) ~[play_2.11-2.4.4.jar:2.4.4]
    at play.GlobalSettings$1.call(GlobalSettings.java:67) ~[play_2.11-2.4.4.jar:2.4.4]
    at play.core.j.JavaAction$$anonfun$7.apply(JavaAction.scala:94) ~[play_2.11-2.4.4.jar:2.4.4]
Caused by: org.springframework.beans.NotReadablePropertyException: Invalid property 'name' of bean class [models.Device]: Bean property 'name' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
    at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:731) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:722) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.validation.AbstractPropertyBindingResult.getActualFieldValue(AbstractPropertyBindingResult.java:99) ~[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.validation.AbstractBindingResult.rejectValue(AbstractBindingResult.java:108) ~[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at play.data.Form.bind(Form.java:366) ~[play-java_2.11-2.4.4.jar:2.4.4]
    at play.data.Form.bindFromRequest(Form.java:222) ~[play-java_2.11-2.4.4.jar:2.4.4]
    at controllers.Devices.update(Devices.java:44) ~[classes/:na]
    at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$4$$anonfun$apply$4.apply(Routes.scala:558) ~[classes/:na]
    at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$4$$anonfun$apply$4.apply(Routes.scala:558) ~[classes/:na]
    at play.core.routing.HandlerInvokerFactory$$anon$4.resultCall(HandlerInvoker.scala:136) ~[play_2.11-2.4.4.jar:2.4.4]
[error] application - 
activator clean
activator clean-files