Mybatis-plus 加入打印sql的log日志

Mybatis-plus 加入打印sql的log日志 yml配置

mybatis-plus:
  # 映射文件的位置
  mapper-locations: classpath:mapper/*.xml
  type-aliases-package: com.qax.ztb.machine.domain.entity
  configuration:
    map-underscore-to-camel-case: true
    cache-enabled: false
    call-setters-on-nulls: true
    jdbc-type-for-null: 'null'
    # 日志打印配置
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl 

控制台打印: will not be managed by Spring

配置好了之后发现另一个问题了:

未注册同步,因为同步未激活

Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7ed9f779] was not registered for synchronization because synchronization is not active
JDBC Connection [oracle.jdbc.driver.T4CConnection@54247b90] will not be managed by Spring

解决办法:
在service的实现加一个注解@Transactional就好

@Service
@Slf4j
@Transactional
public class ProcessServiceImpl {}

你可能感兴趣的:(框架,mybatis,sql,数据库)