Failed to instantiate [org.springframework.context.annotation.AnnotationConfigApplicationContext]: Constructor threw exception;
nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException:
Annotation-specified bean name 'myService' for bean class [my.package.ejb.MyService] conflicts with existing, non-compatible bean definition of same name and class [my.package.other.ejb.MyService]
那些
MyService
接口甚至没有注释,它们代表EJB2.0无状态bean。
我的注释配置如下。
@Configuration
@ComponentScan("my.package")
@MapperScan("my.package")
public class ApplicationConfiguration {
@Bean
public DataSource dataSource() {
return new JndiDataSourceLookup().getDataSource("...");
}
@Bean
public SqlSessionFactoryBean sqlSessionFactory(final DataSource dataSource) {
final SqlSessionFactoryBean sqlSessionFactory = new SqlSessionFactoryBean();
sqlSessionFactory.setDataSource(dataSource);
sqlSessionFactory.setConfigLocation(new ClassPathResource("..."));
return sqlSessionFactory;
}
@Bean
public DataSourceTransactionManager dataSourceTransactionManager(final DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
}