IOC操作Bean管理注解方式(组件扫描配置)
生活随笔
收集整理的這篇文章主要介紹了
IOC操作Bean管理注解方式(组件扫描配置)
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
?
IOC操作Bean管理注解方式(組件掃描配置)
?
開啟組件掃描的 細(xì)節(jié)配置
約定那些類可以掃描,哪些類不可以掃描
?
?bean1.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:p="http://www.springframework.org/schema/p"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!--上面是名稱空間引入--><!--示例1--><!--use-default-filters="false" 表示現(xiàn)在不使用默認(rèn)的filter過濾器,配置自己的filter過濾器規(guī)則--><!--context:include-filter 表示現(xiàn)在要掃描那些內(nèi)容 type="annotation"根據(jù)注解掃描 expression 根據(jù)什么表達(dá)式進(jìn)行掃描--><context:component-scan base-package="com.lbj.spring5" use-default-filters="false"><context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/></context:component-scan><!--示例2--><!--context:exclude-filter 設(shè)置那些內(nèi)容不進(jìn)行掃描--><context:component-scan base-package="com.lbj.spring5.dao" ><context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/></context:component-scan></beans>示意圖:
總結(jié)
以上是生活随笔為你收集整理的IOC操作Bean管理注解方式(组件扫描配置)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Spring的AOP-操作术语
- 下一篇: app inventor2 打地鼠_春节