我正在尝试使用 beanio 将带注释的类写入固定长度文件。所有课程都已注释,但我遇到异常
“记录‘团队’、流‘Tm’中的字段‘员工’无效:找不到类型‘com.mycompany.bio.Employee’的类型处理程序”
下面是我的源代码
public static void main(String[] args) {
StreamFactory factory = StreamFactory.newInstance();
StreamBuilder builder = new StreamBuilder("Tm")
.format("fixedlength")
.parser(new FixedLengthParserBuilder())
.addRecord(com.mycompany.bio.Team.class);
factory.define(builder);
Employee e1 = new Employee("EmpF1", "EmpL1", "Developer", "1", new Date());
Employee e2 = new Employee("EmpF2", "EmpL2", "Developer", "2", new Date());
Team team = new Team();
team.setTeamName("Great Team");
team.getEmployees().add(e1);
team.getEmployees().add(e2);
BeanWriter out = factory.createWriter("Tm", new File("C:\\Users\\user\\Desktop\\tm.dat"));
out.write(team);
out.flush();
out.close();
}
Run Code Online (Sandbox Code Playgroud)
团队类别:
@Record(minOccurs = 1)
public class Team {
// @Segment(collection = ArrayList.class, minOccurs = 0, maxOccurs …Run Code Online (Sandbox Code Playgroud)