java - issues related to springMVC automatic assembly.
淡淡烟草味
淡淡烟草味 2017-05-17 10:08:53
0
3
602

I want to assemble multiple Dao at the same time,

    @Autowired
    WeatherReportDao weatherReportDao;

    @Autowired
    AtmosphereReportDao atmosphereReportDao;

Now it is written like this, can I use @Autowired only once?

淡淡烟草味
淡淡烟草味

reply all(3)
刘奇

Brother, you are quite lazy. This world is for lazy people.
You can write an abstract base class, and then let all your classes that need to do this inherit this base class.
In this way, you don’t have to write Annotated, but the key point is that you still need to write a custom bean factory

刘奇

No, because the annotations are based on the annotations you write based on the scanner, and spring creates the object for you,

伊谢尔伦

No, and it is recommended that you use it@Resource注解替代@Autowired

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!