- 首先是在写<dependency>标签的时候没有自动补全,所以全部手动敲入:
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.4.6</version>
</dependency>
- 用的jdk 17,在paperhelper版本号(1.4.6/2.0.0)上犹豫,并重构了几次,均报错,最终的报错如下(这里可能有各种原因,包括我也一直在重启):
com.fasterxml.jackson:jackson-parent:pom:2.13 failed to transfer from https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact com.fasterxml.jackson:jackson-parent:pom:2.13 from/to central (https://repo.maven.apache.org/maven2): Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.108.215] failed: Read timed out
总结在成功前有以下几项关键操作:
(1)解决网络不稳定问题,配置源:E:\Tools\apache-maven-3.9.0\conf\settings.xml
<mirror>
<id>aliyun</id>
<mirrorOf>central</mirrorOf>
<name>aliyun</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
(2)手动删除了这些目录下已安装好的paperhelper的各版本(注意看目录下的同衍生包):'C:\Users\<你的用户名>\.m2\repository\com\github\pagehelper'
(3)在项目的终端里强制更新Maven依赖
mvn clean install -U
(4)重建项目
- 在顶部菜单中,选择
构建
(Build)。 - 选择
重建项目
(Rebuild Project)。
(5)检查导入
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
注:以上是解决报错的可能性有效操作,不太明白原理,欢迎交流指导