求教Springboot+mybatis的配置

发布网友 发布时间:2022-04-20 00:37

我来回答

2个回答

热心网友 时间:2022-04-09 13:04

@Configuration
@EnableTransactionManagement
@MapperScan("com.*.*.mapper")
public class DataBaseConfig {

private final Logger log = LoggerFactory.getLogger(DataBaseConfig.class);

@Bean
@Primary
@ConfigurationProperties(prefix = "datasource.primary")
public DataSource dataSource() {
log.debug("Configuring Datasource");
return new DruidDataSource();
}

@Bean
public PlatformTransactionManager txManager() {
return new DataSourceTransactionManager(dataSource());
}

@Bean
public SqlSessionFactory sqlSessionFactoryBean() throws Exception {

SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource());

PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();

sqlSessionFactoryBean.setMapperLocations(resolver
.getResources("classpath:/mapper/*.xml"));
return sqlSessionFactoryBean.getObject();
}

}

热心网友 时间:2022-04-09 14:22

defined in file [D:\Workspaces\MyEclipse 10\.metadata\.me_tcat\webapps\SSM\WEB-INF\classes\applicationContext-common.xml 这里是问题的核心, 更具配置文件创建bean失败, 你要好好看一下你的 配置文件了。 错误描述: Context initializ...

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
13.130633s