当前位置:网站首页>Error creating bean with name xxx Factory method ‘sqlSessionFactory‘ threw exception; nested excepti

Error creating bean with name xxx Factory method ‘sqlSessionFactory‘ threw exception; nested excepti

2022-06-23 14:58:00 Gripper

Abnormal log :

 Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxx': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxx': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'payRequestServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'payRequestMapper' defined in file [E:\code\xxx\xxx\target\classes\orm\mapper\XxxMapper.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 [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.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.apache.ibatis.type.TypeException: The alias 'Entity' is already mapped to the value 'com.xxx.Entity'.
 

as a result of MybatisPlus Of typeAliasesPackage The scope of entity scanning package configuration is too large , Lead to spring Two containers with the same name are injected when the container is started Bean Report errors .

terms of settlement :

take .yml In the configuration file mybatis-plus.typeAliasesPackage Narrow the scope of , for example :mybatis-plus.typeAliasesPackage = com.**.**.po

Other methods , You can also use the same name Bean Modify one of the names , In this way, no error will be reported when starting . However, this method can cure the symptoms but not the root causes .

原网站

版权声明
本文为[Gripper]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206231417556041.html