搭建Mybatis環境遇到的問題
阿新 • • 發佈:2020-10-08
1. org.apache.ibatis.binding.BindingException: Type interface com.hsz.dao.UserDao is not known to the MapperRegistry. 解決方法: <!--每一個Mapper.xml都需要在mybatis核心配置檔案中註冊--> <mappers> <mapper resource="com/hsz/dao/UserMapper.xml"/> </mappers> 2. java.lang.ExceptionInInitializerError 解決方法: <!--在build中配置resources,來防止我們資源匯出失敗的問題--> <build> <resources> <resource> <directory>src/main/resources</directory> <excludes> <exclude>**/*.properties</exclude> <exclude>**/*.xml</exclude> </excludes> <filtering>false</filtering> </resource> <resource> <directory>src/main/java</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>false</filtering> </resource> </resources> </build> 3. java.io.IOException: Could not find resource mybatis-config.xml 解決方法: 將放置mybatis-config.xml的資料夾與src放在同一目錄下 4.Caused by: java.sql.SQLException: The server time zone value '�й���ʱ��' is unrecognized or represents more than one time zone. 解決方法: 時差問題:在URL後面加上serverTimezone=GMT%2B8 如:"jdbc:mysql://localhost:3306/mybatis?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8"