今天springboot 出现个错误找了好久错误原因。
错误信息:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController': Unsatisfied dependency expressed through field 'userService': Error creating bean with name 'userService': Unsatisfied dependency expressed through field 'userMapper': Error creating bean with name 'userMapper' defined in file [E:\jeefee\target\classes\com\jeefee\dao\mapper\UserMapper.class]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'mapperHelper' of bean class [org.mybatis.spring.mapper.MapperFactoryBean]: Bean property 'mapperHelper' 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 'userMapper' defined in file [E:\jeefee\target\classes\com\jeefee\dao\mapper\UserMapper.class]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'mapperHelper' of bean class [org.mybatis.spring.mapper.MapperFactoryBean]: Bean property 'mapperHelper' 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.UnsatisfiedDependencyException: Error creating bean with name 'userService': Unsatisfied dependency expressed through field 'userMapper': Error creating bean with name 'userMapper' defined in file [E:\jeefee\target\classes\com\jeefee\dao\mapper\UserMapper.class]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'mapperHelper' of bean class [org.mybatis.spring.mapper.MapperFactoryBean]: Bean property 'mapperHelper' 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 'userMapper' defined in file [E:\jeefee\target\classes\com\jeefee\dao\mapper\UserMapper.class]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'mapperHelper' of bean class [org.mybatis.spring.mapper.MapperFactoryBean]: Bean property 'mapperHelper' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
原因:是因为使用通用mapper的时候不能使用
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> <!-- optional=true,依赖不会传递,该项目依赖devtools;之后依赖该项目的项目如果想要使用devtools,需要重新引入 --> </dependency>
热部署。