`

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

 
阅读更多

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

	<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="locations">
			<list>
				<value>classpath:frameworkconfig/jdbc/MySQL.properties</value>
			</list>
		</property>
	</bean>

 这种方式。

 

最近引入了spring 组件扫描

 	<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-scan
Scans 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/>

 

 

 

分享到:
评论

相关推荐

    spring2.5中文文档

    5. **Bean表达式语言(EL)**:Spring Expression Language (SpEL)是Spring 2.5引入的新特性,提供了一种强大的表达式语言,用于在运行时查询和操作对象图。它可以在配置元数据中使用,也可以在运行时动态操作对象。 ...

    Spring2.5-中文参考手册chm

    Spring2.5中文参考手册是学习和理解Spring框架的重要资源,涵盖了上述所有核心概念和特性。通过深入阅读,开发者可以掌握如何利用Spring 2.5构建高效、灵活且易于维护的企业级应用。无论是在传统的J2EE环境中还是...

    spring2.5的applicationContext配置文件

    2. **依赖注入**:Spring 2.5引入了基于注解的依赖注入(Annotation-Based Dependency Injection, ABDI),使得无需使用XML来声明依赖关系。但同时,XML配置仍然可用。例如,通过`...

    Spring2.5 源代码

    Spring 2.5提供了强大的本地化支持,允许开发者轻松地根据用户的地区提供不同语言的资源。 8. **Struts集成**: 尽管Spring 2.5本身提供了MVC框架,但它也支持与其他Web框架的集成,如Struts。通过Spring的Struts...

    Spring2.5-中文参考手册chm.zip

    这个"Spring2.5-中文参考手册chm.zip"文件包含了关于Spring 2.5版本的详细中文指南,对于学习和理解Spring框架具有很高的价值。 Spring框架的核心特性包括依赖注入(Dependency Injection,DI)、面向切面编程...

    spring2.5需要的jar

    在压缩包"spring2.5需要的jar"中,可能包含了一系列Spring框架的核心库,如spring-core、spring-context、spring-aop、spring-beans、spring-expression等。这些jar文件是构建基于Spring 2.5的应用所必需的,它们...

    spring2.5中文文档(PDF)

    6. **XML Schema支持**:Spring 2.5引入了新的XML Schema,使得配置文件更加语义化和易读。 7. **测试框架**:加强了对JUnit和Mockito等测试工具的集成,便于编写单元测试和集成测试。 8. **国际化支持**:通过`...

    spring 2.5依赖包

    2. **AOP增强**:Spring 2.5引入了对AspectJ的全面支持,包括编译时和运行时的切面织入。这使得AOP的使用更加灵活,可以更方便地定义切面和通知。 3. **Bean工厂和应用上下文**:Spring 2.5对Bean工厂和应用上下文...

    Spring2.5开发PDF+Spring2.5CHM

    而`Spring2.5开发简明教程中文版.pdf`则可能是针对这个版本的一本实用教程,可以帮助读者深入理解Spring 2.5的各种特性和用法。结合这两个资源,开发者可以系统地学习和掌握Spring 2.5的核心概念和技术。

    spring2.5必备jar包

    除了这些,Spring 2.5还引入了对Java Persistence API (JPA) 的全面支持,允许开发者利用ORM(对象关系映射)技术进行数据访问。同时,Spring 2.5在Web MVC方面也做了很多改进,比如支持RESTful风格的URL映射,增强...

    传智播客 spring2.5源代码_lib包

    这个"传智播客 spring2.5源代码_lib包"包含了Spring框架2.5版本的库文件,这些库文件对于理解Spring的工作原理、学习如何使用它以及进行相关开发非常有帮助。下面我们将深入探讨Spring 2.5的一些核心概念和功能。 1...

    spring2.5源码

    Spring 2.5引入了`Resource`接口和相关的实现,提供了一种统一的方式来处理各种类型的资源,包括文件系统、URL、类路径和JAR文件中的资源。 8. **集成第三方库** Spring 2.5加强了与第三方库的集成,如JMS、JPA、...

    spring 2.5

    压缩包中的文件"spring-reference.pdf"很可能是Spring框架的官方参考文档,其中详细介绍了Spring 2.5的各种特性和API用法,是学习和理解Spring框架的重要资源。 "iBATIS-DAO-2_en.pdf"、"iBATIS-SqlMaps-2-Tutorial...

    Spring2.5中文手册

    - 开发者可以通过配置或注解来指定消息资源文件,实现动态替换文本。 9. **单元测试** - Spring Test模块提供了对Spring应用进行单元测试和集成测试的支持,包括`ApplicationContext`的加载和销毁。 - Spring ...

    Spring2.5中文帮助文档

    Spring 2.5引入了JPA(Java Persistence API)支持,提供了一种标准的方式来管理和持久化对象。 6. **国际化支持**:Spring 2.5提供了国际化的消息源,可以方便地处理不同地区的语言和格式。 7. **资源处理**:...

    Spring2.5-中文参考手册(这是个chm格式的文档)

    6. **JSR-303/JSR-349验证**:Spring 2.5引入了对JSR-303/JSR-349 Bean Validation规范的支持,可以方便地进行数据验证,提升应用程序的健壮性。 7. **Spring表达式语言(Spring Expression Language, SpEL)**:SpEL...

    spring2.5 所需所有jar包和源文件

    9. **国际化(i18n)支持**:Spring 2.5提供了更好的国际化支持,可以方便地管理和切换不同语言的资源文件。 10. **测试支持**:Spring 2.5包含了对JUnit和Mockito等测试框架的更好集成,使单元测试和集成测试更加...

    spring2.5 api

    Spring 2.5 引入了注解配置,允许开发者在类和方法级别使用注解,如 @Component、@Service、@Repository 和 @Controller,这些注解对应了传统的 XML 中的 `&lt;bean&gt;` 元素。此外,@Configuration 类可以替代 XML 配置...

Global site tag (gtag.js) - Google Analytics