mybatis 日志 Reader entry 乱码

屠泰平
2023-12-01

mybatis 日志 Reader entry 乱码 问题

现象:乱码日志如下

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

分析:上述日志有两处问题

  1. org.jboss.vfs.VFS 没找到
  2. Reader entry 乱码

由上面两处问题大致可以猜测是由于指定的VFS没有找,mybatis启用了默认的DefaultVFS,然后由于DefaultVFS的内部逻辑,从而导致了reader entry乱码。
所以解决问题的切入点有两个。1: org.jboss.vfs.VFS 2:修改DefaultVFS

  1. 追加org.jboss.vfs.VFS相关的依赖
    由于我是用maven来构建的项目,所以直接加入下面的依赖
     <dependency>
      <groupId>org.jboss</groupId>
      <artifactId>jboss-vfs</artifactId>
      <version>3.2.15.Final</version>
    </dependency>
  1. 看了一下,貌似不用解决,这些乱码是编译后的class文件的一部分,本来就没啥意义,无所谓。不信你可以尝试用文本编辑器打开任意class文件。都长那样
 类似资料: