0

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;
}
Okumura
  • 1
  • 1
  • See [this](https://freecontent.manning.com/understanding-constructor-injection/) and [this](https://freecontent.manning.com/understanding-property-injection/). – Steven May 18 '22 at 16:12

0 Answers0