I faced with problem while using of lombock @Builder.
In SpringBoot application I create the following component:
@Getter
@Builder
@Component
@AllArgsConstructor
public class ContentDTO {
private UUID uuid;
private ContentAction contentAction;
private String payload;
}
But when I run the application< I receive:
Error creating bean with name 'contentDTO': Unsatisfied dependency expressed through constructor parameter 0
Caused by:
No qualifying bean of type 'java.util.UUID' available: expected at least 1 bean which qualifies as autowire candidate
"Finger to the sky", I changed lombock-builder to custom builder, like this:
@Getter
@Component
public class ContentDTO {
private ContentDTO() {
}
// fields
public static Builder newBuilder() {
return new ContentDTO().new Builder();
}
public class Builder{
private Builder() {
private constructor
}
public ContentDTO build() {
return ContentDTO.this;
}
}
}
And problem is gone.
Its nice, but I clearly dont understand, what was problem!
Why in this case lombock-builder prevented the autowiring of beans?
And how to use lombock-builder properly in Spring ApplicationContext?
question from:
https://stackoverflow.com/questions/65829596/spring-properly-use-of-lombock-builder 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…