Heim  >  Fragen und Antworten  >  Hauptteil

Java – Probleme im Zusammenhang mit der automatischen Assemblierung von springMVC.

Ich möchte mehrere Dao gleichzeitig zusammenbauen,

    @Autowired
    WeatherReportDao weatherReportDao;

    @Autowired
    AtmosphereReportDao atmosphereReportDao;

Da es jetzt so geschrieben ist, kann ich @Autowired nur einmal verwenden?

淡淡烟草味淡淡烟草味2712 Tage vor623

Antworte allen(3)Ich werde antworten

  • 怪我咯

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

    哥们你挺懒的,不够这世界就是为懒人服务的,
    你可以写个抽象基类,然后让你的所有需要这么干的类,都继承这个基类,
    这样你就可以不写注解了,但是关键你还是需要写个自定义的bean工厂

    Antwort
    0
  • 怪我咯

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

    不能吧,因为注解是根据扫描器得到你写的注解,spring给你创建对象,

    Antwort
    0
  • 伊谢尔伦

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

    不能,而且建议你使用@Resource注解替代@Autowired

    Antwort
    0
  • StornierenAntwort