Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我试图在Spring引导应用程序中使用AllArgsConstructor,但它没有为所有字段提供默认构造函数?_Java_Spring_Spring Boot_Lombok - Fatal编程技术网

Java 我试图在Spring引导应用程序中使用AllArgsConstructor,但它没有为所有字段提供默认构造函数?

Java 我试图在Spring引导应用程序中使用AllArgsConstructor,但它没有为所有字段提供默认构造函数?,java,spring,spring-boot,lombok,Java,Spring,Spring Boot,Lombok,我有下面的代码,但当我试图在ApplicationRunner中使用它时,它给出了未定义的(提示:请使用字段创建构造函数)。我的pom.xml中已经有lombok jar了 @数据 @NoArgsConstructor(力=真) @AllArgsConstructor @实体 @表(name=“客户”) 类客户{ //公共客户(对象对象、字符串字符串、字符串字符串2、哈希集哈希集){ ////TODO自动生成的构造函数存根 // } // //公共客户(){ // } @身份证 @生成值

我有下面的代码,但当我试图在ApplicationRunner中使用它时,它给出了未定义的(提示:请使用字段创建构造函数)。我的pom.xml中已经有lombok jar了

@数据
@NoArgsConstructor(力=真)
@AllArgsConstructor
@实体
@表(name=“客户”)
类客户{
//公共客户(对象对象、字符串字符串、字符串字符串2、哈希集哈希集){
////TODO自动生成的构造函数存根
//  }
//  
//公共客户(){
//  }
@身份证
@生成值
私人长id;
@列(name=“first_name”)
私有字符串优先;
@列(name=“last_name”)
私有字符串最后;
@OneToMany(cascade=CascadeType.ALL,orphan=true)
@JoinColumn(name=“customer\u fk”)
私有集<顺序>顺序=新哈希集<>();
}
在ApplicationRunner接口的运行方法中使用时=>

@覆盖
公共void运行(ApplicationArguments参数)引发异常{
试一试{
tt.执行(状态->{
Stream.of(“Dave,Syer;Phil,Fisher;Mark,Web.”拆分(“;”)
.map(名称->名称.split(“,”))
.forEach(tpl->this.em.persist(新客户(null,tpl[0],tpl[1],新HashSet<>());
TypedQuerycustomers=this.em.createQuery(“从Customer c中选择c”,Customer.class);
customers.getResultList().forEach(客户->
info(“键入的查询结果为:“+ToStringBuilder.ReflectionString(customer)));
返回null;
});
}捕获(例外e){
e、 getStackTrace();
}
}

请添加stacktrace,并解释您的跑步方法。例如,什么是
tt
?你是如何编译这些课程的?您确定lombok指示的代码是作为类的一部分创建的吗?请提供您的相关部分
pom.xml
,以便我们有一个可操作的完整示例.void jpaaapplicationwriter(EntityManager em,TransactionTemplateTT){this.em=em;this.tt=tt;}@hotzst实际上我使用的是TransactionTemplate和entityManager依赖项。@hotzst我也必须在mac上安装lombok项目。似乎是配置问题。已通过此链接解决:。无论如何,谢谢你:)