首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

spring2.5 引来资源文件的方式

2012-06-26 
spring2.5引入资源文件的方式?以前项目中引入 数据库 连接相关的字符串 都是使用bean idpropertyConfig

spring2.5 引入资源文件的方式

?以前项目中引入 数据库 连接相关的字符串 都是使用

<bean id="propertyConfigurer" name="code"> <context:component-scan base-package="cn.xxt"><context:include-filter type="regex" expression=".action.*"/><context:include-filter type="regex" expression=".service.*"/>        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"/></context:component-scan>

?

后,今天无意中点到了 看到了dtd的提示 中有句 Note: You may use placeholders in package paths, but only resolved
against system properties (analogous to resource paths).

Element : component-scanScans the classpath for annotated components that will be auto-registered as Spring beans. By  default, the Spring-provided @Component, @Repository, @Service, and @Controller stereotypes will  be detected. Note: This tag implies the effects of the 'annotation-config' tag, activating  @Required, @Autowired, @PostConstruct, @PreDestroy, @Resource, @PersistenceContext and  @PersistenceUnit annotations in the component classes, which is usually desired for autodetected  components (without external configuration). Turn off the 'annotation-config' attribute to  deactivate this default behavior, for example in order to use custom BeanPostProcessor definitions  for handling those annotations. Note: You may use placeholders in package paths, but only resolved  against system properties (analogous to resource paths). A component scan results in new bean  definition being registered; Spring's PropertyPlaceholderConfigurer will apply to those bean  definitions just like to regular bean definitions, but it won't apply to the component scan  settings themselves.Content Model : (include-filter*, exclude-filter*)

?

就网上搜索了一下

找到了 还能如下用

<context:property-placeholder location="classpath:frameworkconfig/jdbc/MySQL.properties"/>

?

然后试了如下组合,也能用 上面的

<context:annotation-config/>

?

?

?

热点排行