您的位置:首页 > 编程语言 > Java开发

spring 无法读取properties中的值

2015-12-23 16:55 435 查看
弄了好久,spring中引入配置文件就是读取不到,也上网找了好多文字,大多都是改引入配置文件的方式如:

<context:property-placeholder location="classpath:config/jdbc.properties"/>

或者

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

<property name="locations">

<list>

<value>classpath:jdbc.properties</value>

<!--要是有多个配置文件,只需在这里继续添加即可 -->

</list>

</property>

</bean>

这样引入,都无法达到效果;最后通过修改

<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">

<property name="basePackage" value="com.tgb.mapper;"></property>

<!-- 读取配置文件properties中的值 -->

<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />

<!-- <property name="sqlSessionFactory" ref="sqlSessionFactory"></property> -->

</bean>

把<property name="sqlSessionFactory" ref="sqlSessionFactory"></property> 修改为

<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />

就可以读取到了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: