08-02-2023, 01:19 PM
Which is more correct?
This (with the @Autowired annotation on the method)?
@Controller
public class MyController
{
private MyDao myDao;
@Autowired
public MyController(MyDao myDao)
{
this.myDao = myDao;
}
This (with the @Autowired annotation on the property)?
@Controller
public class MyController
{
@Autowired
private MyDao myDao;
public MyController(MyDao myDao)
{
this.myDao = myDao;
}
Where is the @Autowired annotation supposed to go?
This (with the @Autowired annotation on the method)?
@Controller
public class MyController
{
private MyDao myDao;
@Autowired
public MyController(MyDao myDao)
{
this.myDao = myDao;
}
This (with the @Autowired annotation on the property)?
@Controller
public class MyController
{
@Autowired
private MyDao myDao;
public MyController(MyDao myDao)
{
this.myDao = myDao;
}
Where is the @Autowired annotation supposed to go?