#spring boot启动报Error creating bean with name ‘xxx’: Injection of resource dependencies failed; nested exception is
##我在启动springboot项目时候保错
由于之前都没有报错,ctrl+v 别人的代码之后,报错的,有Error creating bean with name、空指针等等,网上查了许多都没起作用,然后打断点进行解决的,下面一起看看我的异常。
###1、先看报错的源码
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.github.dreamyoung.mprelation.AutoMapper;
@Configuration
public class AutoMapperConfig {
@Bean
public AutoMapper autoMapper() {
return new AutoMapper(new String[] {“com.jincheng.bean”}); //配置实体类所在目录(可多个,暂时不支持通过符*号配置)
}
}
###2、报错信息
Error creating bean with name ‘webSecurityConfig’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘loginAuthenticationProvider’: Unsatisfied dependency expressed through field ‘userService’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘usersServiceImpl’: Unsatisfied dependency expressed through field ‘autoMapper’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘autoMapper’ defined in class path resource [com/xxx/config/AutoMapperConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.github.dreamyoung.mprelation.AutoMapper]: Factory method ‘autoMapper’ threw exception; nested exception is java.lang.NullPointerException: null
3、最初以为jar包没下载等等,由于多方查证无法解决,只能debugger一步一步查看,最后发现是工作空间多写了一个空格,才出现这样的错
![在这里插入图片描述](https://img-blog.csdnimg.cn/c2c527
以后还得小心点,规范命名。。