Spring Tips
Immutable な constructor injection がお勧めです。
@Service
public class FooService {
@Autowired
private BarRepository barRepository;
}
↓ 修正
@Service
public class FooService {
private final BarRepository barRepository;
public FooService(BarRepository barRepository) {
this.barRepository = barRepository;
}
}
↓ Lombok でコードを減らす。
@Service
@RequiredArgsConstructor
public class FooService {
private final BarRepository barRepository;
}