关于applicationContext.xml路径配置

2021-03-28  本文已影响0人  felixfeijs

关于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"/>

二.绝对路径的设置

  1. 要添加file属性,location="file:${SHOP_CONF_ROOT}/worker/config.properties"
  2. linux上${}失效,直接使用写死的路径
上一篇 下一篇

猜你喜欢

热点阅读