2013-03-01 53 views

回答

0

如果你真的需要這個技巧,你可以看看AnnotationConfigBeanDefinitionParser.parse()以檢查它是如何操縱的背景和它註冊什麼樣的bean定義使用它,然後嘗試使用ApplicationContext實現以編程方式重現,以實現相同的效果。

This post可能會幫助您如何將新的bean定義添加到bean註冊表中。

1

我掙扎了很多與這一個,作爲一種解決方法我創建了一個簡單的彈簧方面-config.xml文件中有如下內容

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:context="http://www.springframework.org/schema/context" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans.xsd 
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context.xsd"> 

    <context:spring-configured/> 

,並增加一條,作爲進口到我的應用程序上下文類

@ImportResource("classpath:spring-aspect-config.xml") 

編程可以通過指定

012做同樣的

對您的應用程序上下文類。

參考 - https://jira.springsource.org/browse/SPR-7888

相關問題