美文网首页spark学习
Spark 'generated.java', Line 37,

Spark 'generated.java', Line 37,

作者: mumu_cola | 来源:发表于2019-04-28 10:15 被阅读0次

最近在Spark学习过程中,遇到了如下的错误:

java.util.concurrent.ExecutionException: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 37, Column 53: failed to compile: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 37, Column 53: No applicable constructor/method found for zero actual parameters; candidates are: "LambdaStudy.Person(java.lang.String, java.lang.String, int)"

主要代码部分如下:

@Getter
@Setter
@AllArgsConstructor
public class Person implements Serializable {
    private String firstName;
    private String lastName;
    private int age;
}

@Test
public void dataSetSingleTest() {
    Person person = new Person("four", "li", 32);
    Dataset<Person> dataset = ss.createDataset(
            Collections.singletonList(person),
            Encoders.bean(Person.class)
    );
    dataset.collectAsList();
}

查了许多资料都没有很好的解释。参考错误的提示,我尝试在Person类中添加了一个无参数的构造函数,问题解决。(但根本原因目前还不知道==!)修改代码如下:

@Getter
@Setter
@AllArgsConstructor
public class Person implements Serializable {
    private String firstName;
    private String lastName;
    private int age;
    public Person(){}
}

相关文章

网友评论

    本文标题:Spark 'generated.java', Line 37,

    本文链接:https://www.haomeiwen.com/subject/lwgrnqtx.html