美文网首页
关于applicationContext.xml路径配置

关于applicationContext.xml路径配置

作者: felixfeijs | 来源:发表于2021-03-28 21:21 被阅读0次

关于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上${}失效,直接使用写死的路径

相关文章

网友评论

      本文标题:关于applicationContext.xml路径配置

      本文链接:https://www.haomeiwen.com/subject/pwfjhltx.html