Error creating bean with name 'personnel_Impl': Unsatisfied dependency expressed through field 'personnelMapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personnelMapper' defined in file [C:\Users\Administrator\Desktop\JAVA_WORK\Warehouse_Database\target\classes\com\kybp\dao\personnelMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are requir
报错如上
网上查有说是注释问题 也都加了不知道问题出在哪 springboot项目
xml 的namespace错了,是 com.kybp.dao.mapper.personnelMapper
根据您提供的错误信息,发现是在创建名为 'personnel_Impl' 的 bean 时出现了依赖注入问题。详细错误信息表明,字段 'personnelMapper' 的注入依赖无法满足,并引发了异常。
进一步的错误信息指出,无法创建名为 'personnelMapper' 的 bean,在文件路径 [C:\Users\Administrator\Desktop\JAVA_WORK\Warehouse_Database\target\classes\com\kybp\dao\personnelMapper.class] 中。并且在初始化方法中抛出了 IllegalArgumentException 异常,原因是缺少 'sqlSessionFactory' 或 'sqlSessionTemplate' 属性。
根据报错信息来看,可能有以下几个方面需要检查:
检查是否正确配置了 'personnel_Impl' 和 'personnelMapper' 的 bean。确保这两个 bean 在 Spring Boot 项目中已经正确定义,并且注解或 XML 配置中没有错误。
检查是否正确配置了 'sqlSessionFactory' 或 'sqlSessionTemplate'。请确保相应的配置与 'personnelMapper' 的注入需求相匹配。如果使用 MyBatis 作为持久层框架,需要配置正确的 'sqlSessionFactory' 或 'sqlSessionTemplate',并将其与 'personnelMapper' 相关联。
确保类路径和包名映射正确。根据报错信息中给出的文件路径 [C:\Users\Administrator\Desktop\JAVA_WORK\Warehouse_Database\target\classes\com\kybp\dao\personnelMapper.class],检查对应的类文件是否存在,并且与正确的包名和路径对应。
如果以上步骤都没有解决问题,建议您进一步排查日志文件以获取更详细的错误信息,或联系相关技术人员进行支持和调试。
类名改为首字母大写试试,以与它的实例名进行区分。实例名默认是类名对应的首字母变小写。即:
@Autowired
PersonnelMapper personnelMapper;