spring4+mybatis 配置註解裝載bean

1、web.xml設置監聽

  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
    classpath:SpringConfig*.xml
    </param-value>
  </context-param>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

2、在springconfig.xml中設置自動需要掃描的包

    <context:component-scan base-package="com.jmd" />


3、在需要加載成bean的地方 使用註解方式

@Controller通知spring進行默認加載。


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