at sun.reflect.generics.reflectiveObjects.ParameterizedTypeI
阿新 • • 發佈:2019-01-05
匯入一個新專案,在自己電腦匯入失敗...
報錯,org.apache.ibatis.annotations.Param,如下:
在網上搜了之後說沒匯入ibatis的jar包,因為@Param這個類是ibatis的jar包中的,但是很奇怪,用的是mybatis,之前專案根本沒有匯入那個jar包,直覺告訴我這麼處理是不靠譜的,但是還是嘗試了一下,匯入jar包依賴後,錯誤馬上消失了,慶幸了一下。然而當tomcat執行起來的時候問題就出來了,顯示at sun.reflect.generics.reflectiveObjects.ParameterizedTypeI,這個錯誤原因真是看不懂,最後還是刪了之前導的jar包,直接修改mybatis版本為最新版本(可以在maven中央倉庫查),然後專案就正常了。
原因分析:
原因1:spring整合mybatis的時候,對mybatis的版本是有要求的,如下:
<dependency><--錯誤,不相容--> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.0.1</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.2.2</version> </dependency>
兩個mybatis版本不相容,把第一個dependency的mybatis版本提高的最新就可以解決這個問題了。改變後的結果如下所示:
<dependency><--提高mybatis版本後,正常相容--> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.2.7</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.2.2</version> </dependency>