Spring的JDBC操作

Posted abcdjava

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring的JDBC操作相关的知识,希望对你有一定的参考价值。

 

 

 

1 1 Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘userDaoImpl‘: Unsatisfied dependency expressed through field ‘jdbcTemplate‘: Error creating bean with name ‘jdbcTemplate‘ defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean ‘dataSource‘ while setting bean property ‘dataSource‘; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘dataSource‘ defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property ‘macActive‘ of bean class [com.alibaba.druid.pool.DruidDataSource]: Bean property ‘macActive‘ is not writable or has an invalid setter method. Did you mean ‘maxActive‘?; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘jdbcTemplate‘ defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean ‘dataSource‘ while setting bean property ‘dataSource‘; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘dataSource‘ defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property ‘macActive‘ of bean class [com.alibaba.druid.pool.DruidDataSource]: Bean property ‘macActive‘ is not writable or has an invalid setter method. Did you mean ‘maxActive‘?
2 2  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘jdbcTemplate‘ defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean ‘dataSource‘ while setting bean property ‘dataSource‘; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘dataSource‘ defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property ‘macActive‘ of bean class [com.alibaba.druid.pool.DruidDataSource]: Bean property ‘macActive‘ is not writable or has an invalid setter method. Did you mean ‘maxActive‘?  

 

出现以上报错,可能是在配置阿里巴巴的druid数据源(连接池) 的时候 用$ 连接db.properties配置文件用错“ : ”符号。

技术图片

 

以上是关于Spring的JDBC操作的主要内容,如果未能解决你的问题,请参考以下文章

使用Spring JDBCTemplate简化JDBC的操作

spring系统学习--4 Spring:JDBC Template

如何使用 jdbc/spring-jdbc 不使用 PGInterval 对 PostgreSQL 区间数据类型进行操作?

day39-Spring 17-Spring的JDBC模板:完成增删改的操作

Spring - 整合jdbc

Spring 操作 jdbc 链接数据库