springMVC配置文件中信息(一)

来源:互联网 发布:剑三最美七秀捏脸数据 编辑:程序博客网 时间:2024/05/21 13:54

springMVC 配置文件

第一:

<!-- 采用注释的方式配置bean --><context:annotation-config />

隐式地向 Spring容器注册AutowiredAnnotationBeanPostProcessor、RequiredAnnotationBeanPostProcessor、CommonAnnotationBeanPostProcessor以及PersistenceAnnotationBeanPostProcessor这4个BeanPostProcessor

第二:

<!-- 自动扫描包 --><context:component-scan> 

拥有属性:use-default-filters

    **如果属性为true,就是扫描指定包下的全部的标有@Component,@Service,@Reposity等的类,注册成bean。如下:    <context:component-scan  base-package="org.****.**.***" />**

子标签:<context:incluce-filter>

<context:component-scan  base-package="org.****.**.***" >    <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/></context:component-scan>

这个就只扫描base-package下的标有@Controller的类,注册成bean

第三:

<!-- 数据库配置文件位置 --><context:property-placeholder         location="classpath:jdbc.properties,classpath:config.properties" />

Spring容器只可以定义一个,其余的都会被Spring忽略掉

0 0
原创粉丝点击