Spring使用Maven整合Mybatis问题总结

来源:互联网 发布:网络恐吓怎么解决 编辑:程序博客网 时间:2024/06/06 09:32

以下仅是个人遇到这些问题的解决办法,不一定适用于所有。

  • Mybatis中出现映射文件目录是无效目录
<property name="mapperLocations" value="classpath:com/oaec/mapper/*.xml"></property> 

当我们配置这个的时候,总是报com/oaec/mapper/*.xml是无效的目录,这个时候需要将该配置改成

<property name="mapperLocations" value="classpath*:com/oaec/mapper/*.xml"></property>

即可。

  • Invalid bound statement (not found) 无效的绑定错误

    这个只有在使用maven的时候才会出现这个错误。
    原因:因为maven没有打包xml文件,导致找不到xml文件。
    解决办法:在pom.xml中添加配置

 <resources>     <resource>     <directory>src/main/java</directory>         <includes>          <include>**/*.xml</include>         </includes>    </resource>    <resource>       <directory>src/main/resources</directory>       <includes>        <include>**/*</include>       </includes>    </resource>   </resources>
  • 数据库连接错误
java.sql.SQLNonTransientConnectionException: Could not create connection to database server.java.sql.SQLException: 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.

连接不上数据库,我这里是数据库驱动的版本错误,只需要改变版本即可。