开发者社区> 问答> 正文

springboot集成了mybatis控制台不显示sql语句是为什么

springboot集成了mybatis控制台不显示sql语句是为什么

展开
收起
游客ahv54x37wvm7u 2021-10-28 19:18:22 1221 0
1 条回答
写回答
取消 提交回答
  • 你好,你可以这样做:

    @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;
    

    }

    } 日志实现自己看着办,进去看看都有哪些实现吧你好,你可以这样做:

    @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;
    

    }

    } 日志实现自己看着办,进去看看都有哪些实现吧

    2021-10-28 19:18:42
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
SQL Server在电子商务中的应用与实践 立即下载
SQL Server 2017 立即下载
Java Spring Boot开发实战系列课程【第6讲】:Spring Boot 2.0实战MyBatis与优化(Java面试题) 立即下载