【mybatis】经历的坑……

学习mybatis时候经历的各种bug

  • 问题1:
  • 问题2

问题1:

问题1:The server time zone value ‘�й���׼ʱ��’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the ‘serverTimezone’ configuration property) to use a more specifc time zone value if you want to utilize time zone support.

这个问题主要是由于数据库时间不同步导致的
在数据库链接后面加上【?serverTimezone=UTC】,使得时间同步

<property name="url" value="jdbc:mysql://localhost:3306/mybatisdb?serverTimezone=UTC "/>

问题2

问题2:log4j:WARN No appenders could be found for logger (org.apache.ibatis.logging.LogFactory).
log4j:WARN Please initialize the log4j system properly.

这个问题主要由于没添加log4j的依赖或者log4j的配置文件。

1、依赖添加:

<dependency>
        <groupId>log4jgroupId>
        <artifactId>log4jartifactId>
        <version>1.2.12version>
    dependency>

2、配置文件添加
在这里插入图片描述
在resources文件夹里面添加文件log4.properties
这个文件具体内容如下:
直接拷贝进去就行了。

# Set root category priority to INFO and its only appender to CONSOLE.
#log4j.rootCategory=INFO, CONSOLE            debug   info   warn error fatal
log4j.rootCategory=debug, CONSOLE, LOGFILE

# Set the enterprise logger category to FATAL and its only appender to CONSOLE.
log4j.logger.org.apache.axis.enterprise=FATAL, CONSOLE

# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} %-6r [%15.15t] %-5p %30.30c %x - %m\n

# LOGFILE is set to be a File appender using a PatternLayout.
log4j.appender.LOGFILE=org.apache.log4j.FileAppender
log4j.appender.LOGFILE.File=d:\axis.log
log4j.appender.LOGFILE.Append=true
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=%d{ISO8601} %-6r [%15.15t] %-5p %30.30c %x - %m\n


你可能感兴趣的:(mybatis)