Springcloud学习踩的坑之工程重构

259 阅读1分钟

Background

尚硅谷Springcloud学习p14

遇到的问题

根据下面的步骤,将重复模块打包后,删除对应的entities 在这里插入图片描述 重新启动module 8001 run不起来

8001 run不起来,报错: 2022-10-16 23:18:24.744 ERROR 16328 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed 节选———— org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'paymentController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'paymentServiceImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'paymentDao' defined in file [D:\java_workspace\springcloud\springcloud\cloud-provider-payment8001\target\classes\indi\cloud\springcloud\dao\PaymentDao.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\java_workspace\springcloud\springcloud\cloud-provider-payment8001\target\classes\mapper\PaymentMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'indi.cloud.springcloud.entities.Payment'. Cause: java.lang.ClassNotFoundException: Cannot find class: indi.cloud.springcloud.entities.Payment 显然是实体映射的问题

解决方法

  • 修改yml文件entities的位置

修改前: 修改前 修改后: 修改后

  • 修改mapper.xml‘ 这里也一样把type改掉 在这里插入图片描述