2013-11-27 46 views
0

今天我在我的應用程序中使用了Spring版本。我從Spring 3.1.1開始,當移動到Spring 3.1.3時,我的應用程序在啓動過程中開始拋出NoSuchBeanDefinitionException異常。自Spring 3.1.3以來的NoSuchBeanDefinitionException

org.springframework.beans.factory.NoSuchBeanDefinitionException:否 [nl.my.product.properties.Properties]類型的 匹配豆找到 依賴性:預期至少1豆,其有資格作爲自動裝配 候選爲此依賴。依賴註解:{}

我喜歡這個應用程序上下文配置的屬性豆:

<!-- Gather properties from environment.properties in a map --> 
<bean id="systemProperties" class="nl.my.product.properties.Properties"> 
    <property name="propertyMap"> 
     <map> 
      <entry key="email.from.address" value="${email.from.address}"/> 
      <entry key="site.host" value="${site.host}"/> 
      <entry key="site.protocol" value="${site.protocol}"/> 
      ... 
     </map> 
    </property> 
</bean> 

我自動裝配豆成許多我的控制器和服務,如:

@Autowired 
public ArticleController(ArticleService articleService, PageBlockService pageBlockService, Properties systemProperties) { 
    this.articleService = articleService; 
    this.pageBlockService = pageBlockService; 
    this.properties = systemProperties; 
} 

從Spring 3.1.3開始,爲什麼Spring無法找到我的bean?我嘗試將Properties bean移動到一個包中,以便不掃描組件,但這並不能解決問題。

當我使用@Component註解Properties bean時,Spring會選擇它,但是屬性貼圖是空的。

回答

0

它開始工作,當我從豆的定義中刪除id="systemProperties"

相關問題