报错ERROR:Skipping MapperFactoryBean with name 'xxxMapper' and 'xxx.xxx.xxx.mapper.xxxxxMapper'

报错信息:Skipping MapperFactoryBean with name 'xxxMapper' and 'xxx.xxx.xxx.mapper.xxxxxMapper' nterface. Bean already defined with the same name!

详细报错信息:

2019-07-23 09:25:01.962  INFO 28608 --- [  restartedMain] xxx.xxx.xxxApplication          : Starting xxxApplication on IT-LAPTOP01 with PID 28608 (started by 50015573 in D:\Devops Project\xxxx)
2019-07-23 09:25:01.968  INFO 28608 --- [  restartedMain] com.xxx.xxx.xxxApplication          : No active profile set, falling back to default profiles: default
2019-07-23 09:25:02.046  INFO 28608 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2019-07-23 09:25:02.047  INFO 28608 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2019-07-23 09:25:03.353  WARN 28608 --- [  restartedMain] o.m.s.mapper.ClassPathMapperScanner      : Skipping MapperFactoryBean with name 'studentMapper' and 'com.xxx.xxx.mapper.StudentMapper' mapperInterface. Bean already defined with the same name!
2019-07-23 09:25:03.354  WARN 28608 --- [  restartedMain] o.m.s.mapper.ClassPathMapperScanner      : Skipping MapperFactoryBean with name 'teacherMapper' and 'com.xxx.xxx.mapper.TeacherMapper' mapperInterface. Bean already defined with the same name!
2019-07-23 09:25:03.354  WARN 28608 --- [  restartedMain] o.m.s.mapper.ClassPathMapperScanner      : No MyBatis mapper was found in '[com.xxx.xxx.mapper]' package. Please check your configuration.

2019-07-23 09:25:03.510  WARN 28608 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'statFilter' defined in class path resource [com/alibaba/druid/spring/boot/autoconfigure/stat/DruidFilterConfiguration.class]: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=com.alibaba.druid.spring.boot.autoconfigure.stat.DruidFilterConfiguration; factoryMethodName=statFilter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/alibaba/druid/spring/boot/autoconfigure/stat/DruidFilterConfiguration.class]] for bean 'statFilter': There is already [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=druidConfiguration; factoryMethodName=statFilter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/xxx/xxx/config/DruidConfiguration.class]] bound.
2019-07-23 09:25:03.522  INFO 28608 --- [  restartedMain] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-07-23 09:25:03.524 ERROR 28608 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'statFilter', defined in class path resource [com/alibaba/druid/spring/boot/autoconfigure/stat/DruidFilterConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [com/xxx/xxx/config/DruidConfiguration.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true


Process finished with exit code 0

解决方案:

前几天整体看了一下SpringBoot的简介,觉得看不如自己动手做,于是动手做一个简单的用户管理。启动的时候遇到了
Skipping MapperFactoryBean with name 'sysUserMapper' and 'com.buding.system.mapper.SysUserMapper' mapperInterface. 
Bean already defined with the same name!。警告的意思,是命名与类库中的名字一样了,对于这个警告很是不解。翻了资料也没找到,后来发现配置文件中配置了映射文件目录,而我的entity同时也加了Mapper注解,去掉这个注解,这个警告就消失了。以此记录一下

在启动主文件里面把@MapperScan("com.tony.ssmmd.mapper")注释掉就可以了,只保留配置文件com.xxx.xxx.config.MyBatiesPlusConfiguration里面的@MapperScan("com.xxx.xxx.mapper")
其实两个保留一个就可以了

你可能感兴趣的:(java,springboot,mybatis,Druid)