https://github.com/ChileKasoka/demospring
How do I resolve this error I keep getting. I have a mapper interface called called ‘demoMapper’, and I also have manually configured myBatis to initialize the bean files when the project runs.
Annotation-specified bean name ‘demoMapper’ for bean class [com.example.demo.repository.mapper.DemoMapper] conflicts with existing, non-compatible bean definition of same name and class
mybatisconfig
I have tried creating the MyBatisConfig file with the following code snippet
`package com.example.demo.config;
@Configuration
public class MyBatisConfig {
private final SqlSessionFactory sqlSessionFactory;
public MyBatisConfig(SqlSessionFactory sqlSessionFactory) {
this.sqlSessionFactory = sqlSessionFactory;
}
@Bean
public MapperFactoryBean<DemoMapper> demoMapper() {
MapperFactoryBean<DemoMapper> factoryBean = new MapperFactoryBean<>(DemoMapper.class);
factoryBean.setSqlSessionFactory(sqlSessionFactory);
return factoryBean;
}
}`
Chilekesha Kasoka is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.