Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlTemplate' defined in URL [file:/E:/sources/gitosc/wms-mine/wms-inventory/wms-inventory-web/target/classes/spring-config-dao.xml]: Cannot resolve reference to bean 'sessionFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [file:/E:/sources/gitosc/wms-mine/wms-inventory/wms-inventory-web/target/classes/spring-config-dao.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [sqlmap-config.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: 3 字节的 UTF-8 序列的字节 3 无效。
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:334)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:637)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:145)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1075)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:979)
解决办法如下:点击IDEA的file-settings-editor-file encodings,两个都选择UTF-8,把自己的项目路径添加进来。
如果项目已经生成了class文件,则需要按如下图所示清除class文件,在重新编译生成calss文件,因为你之前格式编码错误的文件已经生成calss文件。如果没有重新编译,那最终jvm执行的还是原先已经生成的非UTF-8的文件,所以导致你修改后还是会报同样的错误,具体如下图:stop tomcat,执行clean然后,你会发现图左边的targer文件没了,如果还存在的话,说明celan失败,重新确认tomcat是不是关掉了;成功之后项目重启即可。