search

Home  >  Q&A  >  body text

java - issues related to springMVC automatic assembly.

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?

淡淡烟草味淡淡烟草味2789 days ago674

reply all(3)I'll reply

  • 怪我咯

    怪我咯2017-05-17 10:10:53

    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

    reply
    0
  • 怪我咯

    怪我咯2017-05-17 10:10:53

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

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-17 10:10:53

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

    reply
    0
  • Cancelreply