Property or field ‘jdbc‘ cannot be found on object of type ‘org.springframework.beans.factory.config.BeanExpressionContext‘ - maybe not public?
// jdbc.username=scott jdbc.password=TIGER jdbc.url=jdbc:oracle:thin:@localhost:1521:orcl jdbc.driver=oracle.jdbc.OracleDriver
<!-- 加载properties配置间 --> <util:properties id="propertiesReader" location="classpath:jdbc.properties"/> <!-- 配置注解扫描器 --> <context:component-scan base-package="com.newer"/> <!-- 配置数据源 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="#{propertiesReader[jdbc.driver]}" /> <property name="jdbcUrl" value="#{propertiesReader[jdbc.url]}" /> <property name="user" value="#{propertiesReader[jdbc.username]}" /> <property name="password" value="#{propertiesReader[jdbc.password]}" /> <property name="minPoolSize" value="2" /> <property name="maxPoolSize" value="20" /> <property name="initialPoolSize" value="8" /> <property name="acquireIncrement" value="2" /> <property name="maxIdleTime" value="120" /> </bean> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> </bean> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.newer.dao" /> </bean> <!-- 加载的时候出现的一些问题 jdbc.password [XXX]中不能有xxx.xxx 必须为一个整体,不然会导致无法被解析--> <!-- 去掉解析jdbc.就可以解决异常问题-->
本文出自 “龙光祥的blog” 博客,转载请与作者联系!
<util:properties id="propertiesReader" location="classpath:jdbc.properties"/>
原文地址:http://18073491002lgx.blog.51cto.com/12044386/1861154