springmvc中使用jdbcTemplate和dbcp

温小乔
  • 43

springmvc中使用jdbcTemplate和dbcp结果出了问题

配置文件如下:
图片描述
repository接口如下:
图片描述

repository实现中的依赖注入部分如下:
图片描述

控制器如下依赖部分如下:
图片描述

报错:

StandardWrapper.Throwable org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'managerController' defined in file [D:\Program Files\Tomcat 7.0\webapps\UserManage\WEB-INF\classes\com\wq\web\managerController.class]: **Unsatisfied dependency expressed through constructor argument with index 0 of type [com.wq.data.UserRepository]**: : Error creating bean with name 'jdbcUserRepository' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'jdbcTemplate' of bean class [com.wq.data.jdbcUserRepository]: Bean property 'jdbcTemplate' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdbcUserRepository' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'jdbcTemplate' of bean class [com.wq.data.jdbcUserRepository]: **Bean property 'jdbcTemplate' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?**

一说控制器的依赖有问题,一说jdbcTemplate有问题...可我实在不明白到底哪里出错了...希望各位指点,谢谢!

回复
阅读 2.9k
4 个回答

因为少了jar包...

j羽竹
  • 4
新手上路,请多包涵

Bean property 'jdbcTemplate' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

你的autowired注解是写在方法上的?还是我见识少。

lywang
  • 3
新手上路,请多包涵

autowired注解是写在成员变量上或者是set方法上的。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
你知道吗?

宣传栏