springboot集成了mybatis为什么控制台不显示sql语句
展开全部
你好,你可以这样做:
@Configuration
public class MyBatisConfig {
@Value("${spring.mybatis.isShowLog}")
private String isShowLog;
@Autowired
private DataSource dataSource;
@Bean(name = "sqlSessionFactory")
public SqlSessionFactoryBean sqlSessionFactory(
ApplicationContext applicationContext) throws Exception {
SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource);
sessionFactory.setPlugins(new Interceptor[] { pageHelper() });
org.apache.ibatis.session.Configuration configuration = new org.apache.ibatis.session.Configuration();
if("true".equalsIgnoreCase(isShowLog)){
configuration.setLogImpl(StdOutImpl.class);
}
sessionFactory.setMapperLocations(applicationContext.getResources("classpath:mapper/*.xml"));
return sessionFactory;
}
}
日志实现自己看着办,进去看看都有哪些实现吧
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询