最近整合SSM整合时,控制台会有ibatis.io.ResolverUtil - Reader entry 乱码情况。
10:33:53.696 [main] DEBUG org.apache.ibatis.io.ResolverUtil - Not a JAR: file:/D:/Java/IdeaProjects/shiyanlou_ssm_test/target/classes/com/ssm/mapper/UserMapper.class
10:33:53.698 [main] DEBUG org.apache.ibatis.io.ResolverUtil - Reader entry: ���� 1 selectLogin *(Lcom/ssm/model/User;)Lcom/ssm/model/User;
10:33:53.731 [main] DEBUG org.apache.ibatis.io.ResolverUtil - Checking to see if class com.ssm.mapper.UserMapper matches criteria [is assignable to Object]
10:33:53.754 [main] DEBUG o.m.spring.SqlSessionFactoryBean - Parsed configuration file: 'class path resource [mybatis-config.xml]'
10:33:53.756 [main] DEBUG o.m.spring.SqlSessionFactoryBean - Property 'mapperLocations' was not specified or no matching resources found
我的依赖版本:
<!-- 自定义的spring的版本号 -->
<spring.version>4.3.14.RELEASE</spring.version>
<!-- 自定义的mybaits的版本号 -->
<mybatis.version>3.4.6</mybatis.version>
<!-- 自定义的mybaits-spring的版本号 -->
<mybatis.spring.version>1.3.2</mybatis.spring.version>
原因是有说日志配置问题,有说版本漏洞,旧版本等。有人也找到了源码的错误地方,是DefaultVFS的InputStreamReader没有传第二个参数导致。:
is = url.openStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
List<String> lines = new ArrayList<String>();
for (String line; (line = reader.readLine()) != null;) {
if (log.isDebugEnabled()) {
log.debug("Reader entry: " + line);
}
lines.add(line);
if (getResources(path + "/" + line).isEmpty()) {
lines.clear();
break;
}
}
mybatis*中DefaultVFS的logger乱码问题:https://www.cnblogs.com/ptqueen/p/7275293.html
好多文章只给出修改配置,没告诉实质性的办法,那么请参考下面的第二点。
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
......
<property name="typeAliasesPackage" value="com.company.project.model" />
......
</bean>
如果配置的是mybatis配置文件,就需要去掉typeAliases
<typeAliases>
......
</typeAliases>
dao
或者mapper
的映射文件*mapper.xml
文件中,引用实体类的地方加上路径,比如Book
改成com.*.*.Book
<select id="queryById" resultType="Book" parameterType="long">
......
</select>
修改后:<select id="queryById" resultType="com.company.project.model.Book" parameterType="long">
......
</select>