'Could not transfer artifact from/to central intellij

My Spring boot project using Maven. When i build it using Intellij Community, i get the error

Could not transfer artifact com.jolira:hickory:pom:1.0.0 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/com/jolira/hickory/1.0.0/hickory-1.0.0.pom

I can build this project success using cmd command line.

My Intellij Community version is:

IntelliJ IDEA 2020.3.1 (Community Edition) Build #IC-203.6682.168, built on December 29, 2020 Runtime version: 11.0.9.1+11-b1145.63 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Windows 10 10.0 GC: ParNew, ConcurrentMarkSweep Memory: 1945M Cores: 8

my pom.xml file

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.5.RELEASE</version>
        <relativePath />
    </parent>
    <groupId>com.super.banana</groupId>

    <!-- Always write artifactId with underscore _ -->
    <artifactId>banana_parent</artifactId>
    <version>1.0.0</version>
    <packaging>pom</packaging>
    <name>bananas_parent</name>
    <description>banana Parent</description>
    <modules>
        <module>bananas-mt</module>
        <module>bananas-web</module>
    </modules>
    <properties>
        <java.version>11</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <commons-io.version>2.6</commons-io.version>
        <commons-lang.version>3.10</commons-lang.version>
        <org.mapstruct.version>1.3.1.Final</org.mapstruct.version>
    </properties>
    <dependencies>
    </dependencies>
</project>

How to fix this issue ?



Solution 1:[1]

Make sure Java version is set correctly for Maven: File > Settings > Build Execution Deployment > Build Tools > Maven > Importing > JDK for importer:

Solution 2:[2]

I had this problem too.

You can try

  1. From IntelliJ Idea, File > Invalidate caches... and then restart
  2. Delete your ~/.m2/repositories directory

Then try again.

If that didn't help, it could be related to IDEA-274458 bug. A workaround is to run mvn clean compile which takes care of downloading artifacts from your command line and then "re-import" the project in IDE.

Solution 3:[3]

This error in Intellij usually comes from bundled maven in the IntelliJ. if you want to use the maven inside the ide (either you can use it in the terminal) its better to force the IntelliJ use the installed maven instead of the bundled one. for this you should go to:

menu choose File -> Setting -> Build, Execution, Deployment ->Build Tools -> Maven.

and change the "maven home path:" from "bundled" to the filepath of installed maven in this case for me is the: "C:/Program Files (x86)/apache-maven-3.6.3"

enter image description here

Solution 4:[4]

I was getting the "Could not transfer artifact [thing] from/to [repo] Transfer failed" error too, and it turned out that I hadn't added my truststore config into IntelliJ's Maven config.

Settings > Build, Execution, Deployment > Build Tools > Maven > Runner

Under "VM Options" add:

-Djavax.net.ssl.trustStore=/path/to/your/truststore.jks

Solution 5:[5]

I was facing the same problem later I got to know that I have selected wrong version of maven, maven 3 was selected in setting-build execution deployment- build tool- maven- maven home path. Then I selected maven 3.8 and my problem resolved.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Makatun
Solution 2
Solution 3 Sajjad Serajzadeh
Solution 4 inanutshellus
Solution 5