在使用Myboot和MyBatis-Plus的时候,写入下面相关的依赖还是一片红色,maven没办法自主导入相关依赖。问题出现的地方主要是lombok和spring-boot-starter-web这两个没法导入。鼠标指针移动到报错的位置说是maven can not 识别这个东西,然后重启几次依旧得不到解决。废话不多说下面是报错的工程,再往下是解决方法。
<dependencies>
<!--数据库驱动-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!--lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!--mybatis-plus -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.0.5</version>
</dependency>
<!--h2-->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
解决方法:
找到setting将Build.Build,Execution,Deployment目录下tool的Maven下的Importing下所圈起来的文件将下图的红标依次找到,打上对勾。
然后就可以都导进去了。
一开始我的解决方法是重启,因为我觉得有可能会是Intellij idea setting显示出错/或者电脑运行过久出错 idea 和Invalidate caches/Restart之后,众所周知重启电脑能解决电脑百分之八十的问题,重启几次后发现问题没解决,然后就这样一番操作下来解决了。