可以混合用。文檔有說明:
Spring can accommodate both styles and even mix them together.
混合用的話,有個先后順序,xml配置會覆蓋annotation。原文:
Annotation injection is performed before XML injection, thus the latter configuration will override the former for properties wired through both approaches.
也就是說對於同一個bean 不能注解完成部分屬性的設定 xml完成部分屬性的設定
xml會覆蓋注解