197639 (4) [Avatar] Offline
#1
The example show a constructor with @Autowired but in spring framework 4.3 some refinements were introduced which make this annotation not necessary in this case

@Autowired
  public JdbcIngredientRepository(JdbcTemplate jdbc) {
    this.jdbc = jdbc;
  }


Craig, can you may mention that?
habuma (277) [Avatar] Offline
#2
197639 wrote:The example show a constructor with @Autowired but in spring framework 4.3 some refinements were introduced which make this annotation not necessary in this case

@Autowired
  public JdbcIngredientRepository(JdbcTemplate jdbc) {
    this.jdbc = jdbc;
  }


Craig, can you may mention that?


Indeed, I thought I did mention it somewhere. Hmmm...I'll dig around and see what happened to that bit. (I think it was in a sidebar.) That said...I am on the fence on whether I'd still use @Autowired, even if it is optional, for the sake of clarity. If I'm writing my own constructor, I feel compelled to include the annotation. But if I'm letting Lombok create a constructor for me, then it's nice to let the implicit @Autowired take effect.