spring 的数据源配置出错Error creating bean with name 'dataSource' defined
来源:互联网 发布:手机淘宝开店教程视频 编辑:程序博客网 时间:2024/06/08 09:39
如果spring配置是使用这种方式传递的properties文件
这里是直接以容器来加载文件
但是username这个属性已经存在在容器中和配置文件中的属性冲突了
所以在配置数据源的时候
传递给username的value使用${username}得不到正确的值
<context:property-placeholder location="classpath:properties/dbconfig.properties" />
<bean id="dataSource" class="..." init-method="init" destroy-method="close"> <property name="username" value="${username}" ><bean>
解决:
1.在db.properties将username属性修改一下
uname: root
然后在spring配置的dataSource里修改属性值:
<property name="username" value="${uname}" >
2.修改spring配置的
<context:property-placeholder location="classpath:properties/dbconfig.properties" />
替换,
以这种方式引入配置文件
是以配置第三方bean的方式配置属性,所以这个bean中的属性是不会和容器中的属性冲突的
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <!-- PropertyPlaceholderConfigurer类中有个locations属性,接收的是一个数组,即我们可以在下面配好多个properties文件 --> <property name="location" value="classpath:properties/dbconfig.properties" /> </bean>
这里记录下…
阅读全文
0 0
- spring 的数据源配置出错Error creating bean with name 'dataSource' defined
- Error creating bean with name 'dataSource' defined in URL
- Error creating bean with name 'dataSource' defined in ServletContext resource
- Spring 整合Hibernate报错:Error creating bean with name 'dataSource' defined in class path resource
- Error creating bean with name 'sessionFactory' defined
- error creating bean with name 'XXXXXX' defined......
- Error creating bean with name 'propertyConfigurer' defined
- Hibernate的Error creating bean with name 'sessionFactory' defined 。。。错误
- Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml]:
- Error creating bean with name 'dataSource' defined in class path resource
- Error creating bean with name 'costController'可能出错的原因
- creating bean with name 'dataSource' defined in class path resource错误的解决办法
- Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml]: Initialization of bean faile
- Spring 报错:Error creating bean with name的解决方法
- Spring异常:Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/classes/applicationContext.
- Spring Error creating bean with name 'sessionFactory ' defined in ServletContext resource [/WEB-INF/
- spring异常解决方法Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-
- Spring异常:Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF
- Scalable Big Data Architecture.pdf 英文原版 免费下载
- 纯搭建Hibernate web项目框架
- Python学习笔记--基础篇2
- Big Data Analytics with Spark.pdf 英文原版 免费下载
- L1-041. 寻找250
- spring 的数据源配置出错Error creating bean with name 'dataSource' defined
- UC/OS-II操作系统结构
- method_Robust PCA
- Linux预习进程
- 【SQL】SQL Server 2008数据表管理
- Pro Docker.pdf 英文原版 免费下载
- capsule network
- spring mvc RestFul风格PUT方法修改上传文件
- keras 损失函数汇总