关于applicationContext.xml
关于 <bean>、<context>
一. 相对路径的设置
1. bean的 classpath方式(指的是/src/main/resource/
的路径)
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:sqlMapConfig.xml"></property>
<property name="mapperLocations" value="classpath*:mapper/**/*Mapper.xml"> </property>
</bean>
2. context的location属性,类似
<context:property-placeholder
location="classpath:/base/base.properties" file-encoding="UTF-8" ignore-unresolvable="true"/>
- 也可以使用通配符
*
<context:property-placeholder
location="classpath:*.properties" file-encoding="UTF-8" ignore-unresolvable="true"/>
二.绝对路径的设置
- 要添加
file
属性,location="file:${SHOP_CONF_ROOT}/worker/config.properties"
- linux上
${}
失效,直接使用写死的路径
网友评论