Lombok supports the creation of constructors with annotations @Inject:
@RequiredArgsConstructor(onConstructor = @__(@Inject))
So instead
@Service
public class FooService {
private final BarService barService;
@Inject
public FooService(BarService barService) {
this.barService = barService;
}
}
You can write
@Service
@RequiredArgsConstructor(onConstructor = @__(@Inject))
public class FooService {
private final BarService barService;
}
My problem with this feature is that it seems to interrupt w760> IDE support in IntelliJ:
- In a version other than Lombok, the IDE shows me where the autodetect arguments come from, and allows me to navigate to their location (here's the implementation
BarService). - In the Lombok version, I cannot get it to work. It still shows the location of the Spring bean ad, but not the location of startup-dependent ones.
, . , , Lombok. , :
Spring IDEA Lombok onConstructor = @__(@Inject)?