在spring配置文件中加上 <context:property-placeholder location="classpath:jdbc.properties" />载入jdbc的驱动时,抛出一下异常:
Could not load driverClass ${jdbc.driverClass}
java.lang.ClassNotFoundException: ${jdbc.driverClass}
原因:
在spring里使用org.mybatis.spring.mapper.MapperScannerConfigurer 进行自动扫描的时候,设置了sqlSessionFactory 的话,可能会导致PropertyPlaceholderConfigurer失效,也就是用${jdbc.username}这样之类的表达式,将无法获取到properties文件里的内容。 导致这一原因是因为,MapperScannerConigurer实际是在解析加载bean定义阶段的,这个时候要是设置sqlSessionFactory的话,会导致提前初始化一些类,这个时候,PropertyPlaceholderConfigurer还没来得及替换定义中的变量,导致把表达式当作字符串复制了。 但如果不设置sqlSessionFactory 属性的话,就必须要保证sessionFactory在spring中名称一定要是sqlSessionFactory ,否则就无法自动注入。又或者直接定义 MapperFactoryBean ,再或者放弃自动代理接口方式。
原文:
http://www.oschina.net/question/188964_32305
分享到:
相关推荐
context:property-placeholder 和util:properties 博客:https://blog.csdn.net/u010476739/article/details/76735527
主要介绍了Spring整合Mybatis使用<context>时的坑 的相关资料,非常不错,具有参考借鉴价值,需要的朋友可以参考下
SSH笔记-通过property-placeholder使用外部属性文件的demo
本篇文章主要介绍了Spring中property-placeholder的使用与解析详解,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
html5为input添加了原生的占位符属性placeholder,高级浏览器都支持这个属性,例如: <input type="text" placeholder="搜索" value=" "> 默认的placeholder字体颜色是呈浅灰色,如果想改变这个默认颜色,解决...
Laravel开发-placeholder 用于使用占位符图像服务向应用程序添加图像的Laravel包。
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans ...
webpack-image-placeholder-loader 该加载器从给定图像生成彩色或纯色图像,用作占位符。 该程序包在内部使用。 有关从图像派生的,请参见。 支持JPEG,PNG,WebP,TIFF,GIF和SVG图像。 例子 安装 使用npm安装:...
更好的占位符polyfill [placeholder] polyfill for placeholder属性非常有用,尽管在某些 UI 中具有“可选”...这会将bower_components -placeholder- bower_components的最新版本克隆到项目根目录下的bower_compon
<context:property-placeholder location="classpath:jdbc.properties"/> <!-- 配置数据库连接池 --> <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method...
var getPlaceholderModule = require ( 'quill-placeholder-module' ) . default // umd var getPlaceholderModule = PlaceholderModule . default Quill . register ( 'modules/placeholder' , ...
前端项目-placeholder-shiv,占位符属性的小polyfill。需要prototype.js或jquery
在项目中包含angular-placeholder.min.js文件(不要忘记将ngPlaceholder DI添加到您的应用程序中),并使用如下指令: <input type="text" ng-placeholder placeholder="This is placeholder text" /> 这将...
角占位符垫片 使 input/textarea 占位符属性适用于所有浏览器的 Angular 指令。... script src =" components/angular-placeholder-shim/angular-placeholder-shim.js " > </ script > 将模块placeh
TinyMCE 的占位符文本插件 这个插件为 TinyMCE 编辑器带来了 HTML5 占位符属性功能。 用法 将插件脚本添加到页面 将“占位符”添加到 tinymce 配置插件数组。... 像往常一样向 textarea 添加占位符属性。 享受!
前端项目-placeholder.js,图像占位符使用画布完全在浏览器中呈现图像占位符。
自定义input的placeholder属性为pro,细节自己看源码,源码不多,容易理解
一个简单的图像占位符组件,它使用很多占位符站点中的一些+时髦的赃物组件。 为什么? 这里有很多占位符站点,我将它们重新组合为一个不错的小组件,以及他的弟弟(NicolasCage,BillMurray,StevenSeagal和...
开始使用 安装 npm i react-native-shimmer-placeholder --save 要么 yarn add react-native-shimmer-placeholder 用法 简单 对于expo import ShimmerPlaceholder from ' react-native-shimmer-placeholder ' ...
xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">...