tansitao110
tansitao110
采纳率0%
2016-09-14 08:16 阅读 17.0k

springboot mybatis 整合后怎么答应输出sql语句

关于springboot mybatis 整合后,我想看到mybatis的sql语句日志输出,贴出我的Application.java代码

@SpringBootApplication //等价于@ComponentScan+@EnableAutoConfiguration+@Configuration
@MapperScan("cn.no7player.mapper")
public class Application {
private static Logger logger = Logger.getLogger(Application.class);

@Bean
@ConfigurationProperties(prefix="spring.datasource")
public DataSource dataSource() {
    return new org.apache.tomcat.jdbc.pool.DataSource();
}


@Bean
public SqlSessionFactory sqlSessionFactoryBean() throws Exception {


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


    PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();


    sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:/mybatis/*.xml"));


    return sqlSessionFactoryBean.getObject();
}


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



/**
 * Start
 */
public static void main(String[] args) {

    SpringApplication.run(Application.class, args);
    logger.info("SpringBoot Start Success");
}

}

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • fhg12225 fhg12225 2016-09-14 13:06

    将logger的级别设置为debug 默认的info是不会输出sql的。

    点赞 评论 复制链接分享
  • juanmiao 木子-轩 2017-09-18 06:47

    是的,是不能输出sql语句的

    点赞 评论 复制链接分享

相关推荐