现象:乱码日志如下
2021-03-04 10:59:13 -0 [main] DEBUG - Logging initialized using 'class org.apache.ibatis.logging.log4j.Log4jImpl' adapter.
2021-03-04 10:59:19 -6584 [main] DEBUG - Class not found: org.jboss.vfs.VFS
2021-03-04 10:59:19 -6584 [main] DEBUG - JBoss 6 VFS API is not available in this environment.
2021-03-04 10:59:19 -6586 [main] DEBUG - Class not found: org.jboss.vfs.VirtualFile
2021-03-04 10:59:20 -7256 [main] DEBUG - VFS implementation org.apache.ibatis.io.JBoss6VFS is not valid in this environment.
2021-03-04 10:59:21 -8111 [main] DEBUG - Using VFS adapter org.apache.ibatis.io.DefaultVFS
2021-03-04 10:59:21 -8112 [main] DEBUG - Find JAR URL: file:/E:/framework_learn1/mybatis00101/mybatis00101/target/classes/edu/wangyan/entity
2021-03-04 10:59:21 -8112 [main] DEBUG - Not a JAR: file:/E:/framework_learn1/mybatis00101/mybatis00101/target/classes/edu/wangyan/entity
2021-03-04 10:59:21 -8203 [main] DEBUG - Reader entry: Account.class
2021-03-04 10:59:21 -8204 [main] DEBUG - Reader entry: Course.class
2021-03-04 10:59:21 -8204 [main] DEBUG - Reader entry: Student.class
2021-03-04 10:59:21 -8204 [main] DEBUG - Reader entry: Table.class
2021-03-04 10:59:21 -8204 [main] DEBUG - Reader entry: User.class
2021-03-04 10:59:21 -8204 [main] DEBUG - Listing file:/E:/framework_learn1/mybatis00101/mybatis00101/target/classes/edu/wangyan/entity
2021-03-04 10:59:21 -8204 [main] DEBUG - Find JAR URL: file:/E:/framework_learn1/mybatis00101/mybatis00101/target/classes/edu/wangyan/entity/Account.class
2021-03-04 10:59:21 -8205 [main] DEBUG - Not a JAR: file:/E:/framework_learn1/mybatis00101/mybatis00101/target/classes/edu/wangyan/entity/Account.class
2021-03-04 10:59:21 -8210 [main] DEBUG - Reader entry: ���� 4 E
2021-03-04 10:59:21 -8211 [main] DEBUG - Find JAR URL: file:/E:/framework_learn1/mybatis00101/mybatis00101/target/classes/edu/wangyan/entity/Course.class
2021-03-04 10:59:21 -8212 [main] DEBUG - Not a JAR: file:/E:/framework_learn1/mybatis00101/mybatis00101/target/classes/edu/wangyan/entity/Course.class
2021-03-04 10:59:21 -8214 [main] DEBUG - Reader entry: ���� 4 K 4
分析:上述日志有两处问题
由上面两处问题大致可以猜测是由于指定的VFS没有找,mybatis启用了默认的DefaultVFS,然后由于DefaultVFS的内部逻辑,从而导致了reader entry乱码。
所以解决问题的切入点有两个。1: org.jboss.vfs.VFS 2:修改DefaultVFS
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-vfs</artifactId>
<version>3.2.15.Final</version>
</dependency>