看到這篇文章的小夥伴們,不知道你們使用IDEA的pageHelper插件時是否也遇到了類似於下面這種錯誤呢
java.lang.ClassNotFoundException: Cannot find class: com.github.pagehelper.PageIntercepetor
java.lang.ClassNotFoundException: Cannot find class: com.github.pagehelper.PageHelper
必須要指出的一點是,在5.x版本,mybatis-config.xml中配置pageHelper的格式爲:
<plugins>
<plugin interceptor="com.github.pagehelper.PageInterceptor">
<!-- config params as the following -->
<!--分頁參數合理化-->
<property name="reasonable " value="true"/>
</plugin>
</plugins>
而在4.x版本中,mybatis-config.xml中的配置爲:
<plugins>
<plugin interceptor="com.github.pagehelper.PageHelper">
<!-- config params as the following -->
<property name="reasonable " value="true"/>
<!--<property name="dialect" value="mysql" />-->
</plugin>
</plugins>
如果你們想知道爲什麼,那麼可以在jar包中查看到4.x版本的PageHelper實現了Interceptor接口,而在5.x版本當中由PageInterceptor來實現Interceptor接口,PageHelper繼承了Dialect類。
看到這裏時,你已經確認過你的版本沒問題了,那麼爲什麼還是會報錯呢,而且弄得你快要絕望了呢,那麼我就來揭祕了,也許這可能不是你所遇到的錯誤,但我也希望能與你分享!!
點擊project structure
看到有兩個剛剛加入的依賴,然後需要放入外部根目錄包下,爲什麼要這麼做,我也不太清楚哈哈哈哈,只不過我一直都是這樣做的,不然連服務器都啓動不了,聽說這個操作類似於導包後的Build path功能。
然後重新啓動服務器就應該成功了,前提是你的版本號要和配置文件的配置格式要對的上哦!祝你成功,加油!!!