SSH整合出現的錯誤

做了一個SSH整合的小程序,出現瞭如下錯誤:

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'mapService' is defined

因爲applicationContext.xml裏引用到了ssh.xml,ssh.xml裏面的確定義了bean:mapService

<bean id="mapService" class="yao.service.MapService">
      <constructor-arg>
      <!-- 通過構造方法的參數將MapDAO對象傳入業務邏輯層組件 -->
      <ref bean="mapDAO" />
      </constructor-arg>
  </bean>
錯誤出在配置文件上,挨個找applicationContext.xml、Struts-config.xml和web.xml最後發現web.xml裏面沒有定義ssh.xml的路徑。在web.xml加上如下內容:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/ssh.xml,/WEB-INF/applicationContext-*.xml</param-value>
 </context-param>

就沒有錯誤了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章