In Spring Boot I know this two methods of dependency injections are substitutes but which is better or what are the difference between them?
Dependency injection through constructor:
@Component
public class SomeService {
private final SomeOtherService someOtherService;
public SomeService(SomeOtherService someOtherService){
this.someOtherService = someOtherService;
}
}
Dependency injection through property:
@Component
public class SomeService {
@Autowired
private SomeOtherService someOtherService;
}