此时首先执行一下 mvn compile,看看报不报错,如果不报错那么在 pom.xml中的 <build> 标签后面增加一句
<defaultGoal>compile</defaultGoal>
如下
<build>
<defaultGoal>compile</defaultGoal>
<plugins> <!-- <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId>
</plugin> -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
2、此时如果执行mvn clean install 还报错 ,那么查看 pom.xml的权限,看看自己的用户用没有权限,如果是 root 权限,那么别的用户执行mvn clean就会报错。
ll pom.xml
给自己的用户授权
chown -R user1:user1 pom.xml
此时就可以了
3、如果本地已经安装了指定的jar 包,但是项目中还是报这个jar 没有找到,那么请查看idea 的maven 配置, 首先 ctrl +alt + s,然后 搜索框输入 maven ,找到下面两处察看是否正确。(由于 idea默认的位置 在/root/.m2/repo下,所以这里需要查看是自己安装的位置不)