admin管理员组文章数量:1026989
报错原因:springboot自动注入,启动报错了。
没有找到对应的Bean的原因是@SpringBootApplication没有扫描到
Description:
Field userEntityMapper in com.xxx.xxx.service.UserService required a bean of type 'com.xxx.xxx.dao.UserEntityMapper' that could not be found.
Action:
Consider defining a bean of type 'com.xxx.xxx.dao.UserEntityMapper' in your configuration.
解决方法
1.检查自己写的注解是否错了。
2.在springboot的配置文件添加,mybatis的配置如下所示:
mybatis:
typeAliasesPackage: com.xxx.xxx.dao.entity
mapperLocations: classpath:mapper/*.xml
①将接口与对应的实现类放在与application启动类的同一个目录或者他的子目录下,这样注解可以被扫描到。
②或在启动类上加上@MapperScan或者@ComponentScan注解,手动指定application类要扫描哪些包下的注解,如下所示:
@SpringBootApplication
@ComponentScan(basePackages = {"com.xxx.xxx.dao"})
③或者在接口上添加@Mapper注解。
@Mapper
public interface UserMapper {
}
点击资料获取
报错原因:springboot自动注入,启动报错了。
没有找到对应的Bean的原因是@SpringBootApplication没有扫描到
Description:
Field userEntityMapper in com.xxx.xxx.service.UserService required a bean of type 'com.xxx.xxx.dao.UserEntityMapper' that could not be found.
Action:
Consider defining a bean of type 'com.xxx.xxx.dao.UserEntityMapper' in your configuration.
解决方法
1.检查自己写的注解是否错了。
2.在springboot的配置文件添加,mybatis的配置如下所示:
mybatis:
typeAliasesPackage: com.xxx.xxx.dao.entity
mapperLocations: classpath:mapper/*.xml
①将接口与对应的实现类放在与application启动类的同一个目录或者他的子目录下,这样注解可以被扫描到。
②或在启动类上加上@MapperScan或者@ComponentScan注解,手动指定application类要扫描哪些包下的注解,如下所示:
@SpringBootApplication
@ComponentScan(basePackages = {"com.xxx.xxx.dao"})
③或者在接口上添加@Mapper注解。
@Mapper
public interface UserMapper {
}
点击资料获取
本文标签: BeandefiningTypeConfigurationxxx
版权声明:本文标题:解决Consider defining a bean of type ‘XXX’ in your configuration. 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/jiaocheng/1738333286a1562214.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论