是否存在@Configurable註釋的任何XML等價物?Spring中@Configurable註釋的XML等價物
例如,對於豆:
<bean class="org.obliquid.sherd.domain.SalesDocument" scope ="prototype">
<property name="docType" ref="documentTypeProto"/>
</bean>
我怎麼能告訴SalesDocument應該是@Configurable?
是否存在@Configurable註釋的任何XML等價物?Spring中@Configurable註釋的XML等價物
例如,對於豆:
<bean class="org.obliquid.sherd.domain.SalesDocument" scope ="prototype">
<property name="docType" ref="documentTypeProto"/>
</bean>
我怎麼能告訴SalesDocument應該是@Configurable?
否 - @Configurable
將屬性注入非Spring bean對象的目的。在您的示例中,SalesDocument
已經是Spring bean,並且docType
將被注入。
不是如果我用DAO裏面的新創建它,但是。 – stivlo
在這種情況下,請勿使用new,請使用applicationContext.getBean(「salesDocument」) – sourcedelica
沒有辦法簡單地做到這一點,我意識到這一點。
實現您想要的一種方法是使用基於Spring AspectJ的AOP擴展。這將是很多工作,但如果你知道你的DAO需要有限的配置(可能只是EntityManager
?)它可能是可行的。
查看at the spring reference docs瞭解詳情。
不是你的問題的答案,但如果你需要在春季增強配置支持,請看看Constretto:https://github.com/constretto/constretto-core – ebaxt