解决IntelliJ无法导入maven包的问题

Posted ZeroTensor

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解决IntelliJ无法导入maven包的问题相关的知识,希望对你有一定的参考价值。

使用如下的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.nowcoder</groupId>
    <artifactId>toutiao</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>toutiao</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.8.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-velocity</artifactId>
        </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>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>

在maven -> reimport 时出现如下的错误

Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:1.3.8.RELEASE from/to alimaven (http://maven.aliyun.com/nexus/content/repositories/central/): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

网上的方法都不靠谱,最后使用这个办法解决:

https://maven.aliyun.com/mvn/search 中使用GAV搜索

group : spring-boot-starter-parent
artifactId: spring-boot-starter-parent
version: 1.3.8.RELEASE
把.pom文件下载到maven仓库的org/springframework/boot/spring-boot/1.3.8.RELEASE/中

然后重新reimport就可以了

以上是关于解决IntelliJ无法导入maven包的问题的主要内容,如果未能解决你的问题,请参考以下文章

IntelliJ IDEA导入Maven之后强制刷新项目解决无法识别为Maven项目的问题

Maven 包有效,但 Intellij 的构建失败

Intellij idea 无法解决 maven 中的任何问题

Intellij IDEA在maven项目中添加外部Jar包运行

Intellij IDEA中Maven解决依赖失效

Intellij IEDA 配置Maven 无效