13

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 do I fix this issue?

Snostorp
  • 544
  • 1
  • 8
  • 14
Tung Vo
  • 2,227
  • 5
  • 27
  • 45

9 Answers9

17

Solution 1: I have fixed this issue, in menu choose File -> Setting -> Build, Execution, Deployment ->Build Tools -> Maven. In section User setting file stick Override and browse to settings.xml of Maven (in my case the settings.xml file in directory ..\apache-maven-3.6.3\conf .

I have proxy configuration in settings.xml) enter image description here

Solution 2:

In my case I have problem with com/jolira/hickory/1.0.0/hickory-1.0.0.pom

Similar your case with another library

I go to repository of hickory on https://mvnrepository.com

enter image description here

I download .jar file and .pom file from maven page

enter image description here

Go to {your .m2 directory home}.m2\repository\com\jolira\hickory\1.0.0 and paste the hickory-1.0.0.jar and the hickory-1.0.0.pom to there

enter image description here

open command line and run mvn clean install again. It should sucessful

Solution 3

Go to your Maven directory in local machine computer. Inside directory ..\apache-maven-(version)\conf (in my case E:\soft\apache-maven-3.8.4\conf), open settings.xml and add proxy configuration to this file. Back to your project directory, open command line cmd and run mvn clean install. Back to IntelliJ and reload.

enter image description here

Solution 4

In IntelliJ, choose File->Setting, search Proxy. Choose Proxy tab and enter proxy information from there.

enter image description here

Enter proxy information, press Apply button and press OK Click on Maven panel on the right side of IntelliJ and choose icon reload

enter image description here

enter image description here

Tung Vo
  • 2,227
  • 5
  • 27
  • 45
  • 4
    I'm not sure how this fixes the problem. Did you have something weird in your `settings.xml` file and changing to the default one got rid of it? – Jeff Walker Sep 22 '21 at 14:35
  • 1
    For me it was a proxy issue. If your network is setup to go through a proxy server, then you have to let maven know about that proxy on the user's settings.xml – Teabx Dec 29 '21 at 11:10
  • @JeffWalker, sure. I have a proxy configure in file settings.xml – Tung Vo Jul 11 '22 at 06:16
8

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

Makatun
  • 947
  • 10
  • 11
3

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.

Iraj Hedayati
  • 1,478
  • 17
  • 23
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

Sajjad Serajzadeh
  • 334
  • 1
  • 3
  • 13
2

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
inanutshellus
  • 9,683
  • 9
  • 53
  • 71
1

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.

Unknown
  • 11
  • 2
1

This link helped me: https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000759324-Maven-SSL-switch-off

the trick was to add VM options:

-Dmaven.wagon.http.ssl.insecure=true
-Dmaven.wagon.http.ssl.allowall=true
-Dmaven.wagon.http.ssl.ignore.validity.dates=true

There are two places where you can add them, second place fixed the issue for me.

1. Settings -> Maven -> Runner -> VM options   
2. Settings -> Maven -> Importing -> VM options for importer
0

Make sure you have the correct Java version selected here - For me, it was using the internal Java version and as soon as I selected the correct version(set as JAVA_HOME, it worked) enter image description here

0

First check whether maven is installed by

mvn -version

If it is not showing the version, please install and add the environment variables for maven.