Spring 2.5リソースファイルの導入方法
2743 ワード
以前のプロジェクトでデータベース接続を導入した文字列はすべて使用されています.
この方式.
最近springコンポーネントスキャンが導入されました
その後、今日は何気なくdtdを見たヒントにNote:You may use placeholders in package paths,but only resolved against system properties(analogous to resource paths).
ネットで検索してみました
見つけたら次のように使えます
そして以下の組み合わせを試してみましたが、上の
<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/>