编程语言
首页 > 编程语言> > java-Typesafe Activator:“运行”有效,但“启动”失败并显示错误

java-Typesafe Activator:“运行”有效,但“启动”失败并显示错误

作者:互联网

我正在使用Java Play框架进行项目.直到现在,我始终通过执行./activator run来进行测试,该程序运行正常.现在,我想尝试通过运行./activator start来部署它.但是,这会引起编译错误,我也不知道为什么,因为代码似乎是有序的.

错误:

[error] /home/ghijs/psopv/psopv-2015-groep13/Code/activator-CodeSubmission/app/helpers/Login.java:12: illegal cyclic reference involving method Login
[error] public class Login {
[error]              ^
[error] one error found
[error] (compile:doc) Scaladoc generation failed
[error] Total time: 16 s, completed Jun 4, 2015 2:02:31 PM

“登录”类:

package helpers;

import models.User;
import play.Logger;
import play.data.Form;
import play.data.validation.Constraints.MinLength;
import play.data.validation.Constraints.Required;

public class Login {

    @Required
    @MinLength(4)
    private String username;

    @Required
    @MinLength(5)
    private String password;

    private String userID;
    private User.UserType userType;

    public void Login(String usrnm, String psswrd){
        username = usrnm;
        password = psswrd;
    }

    public String getUsername()         {return username;}
    public String getPassword()         {return password;}
    public String getUserID()           {return userID;}
    public User.UserType getUserType()  {return userType;}

    public void setUsername(String u){username = u;}
    public void setPassword(String p){password = p;}


    public final static Form<Login> LOGIN_FORM = new Form(Login.class);

    public String validate(){
        Logger.info("Validating login info ...");
        User u = User.authenticate(username, password);
        if(u == null) {
            Logger.error("Invalid username or password.");
            return "Invalid user or password";
        }
        else {
            Logger.info("Validating login info ... OK");
            userID = u.getIdentifier();

            userType = u.getUserType();
            return null;
        }
    }
}

我需要这样做是因为./activator dist引发相同的错误,并且我需要能够创建该程序的可分发版本.

解决方法:

public void Login(String usrnm, String psswrd){
    username = usrnm;
    password = psswrd;
}

这不是构造函数.删除关键字void.请记住,没有表单的默认构造函数将导致运行时异常.

标签:typesafe-activator,scala,sbt,playframework-2-0,java
来源: https://codeday.me/bug/20191120/2042217.html