0
votes

I am downloading a project from Spring Initializr and pasting it to Intellij idea. This issue keeps persisting

Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.3.3.RELEASE from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.3.3.RELEASE/spring-boot-starter-parent-2.3.3.RELEASE.pom ProxyInfo{host='123.45.6.78', userName='null', port=80, type='http', nonProxyHosts='null'}

My Pom.xml is as follows.

<?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.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>rooms</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>rooms</name>
    <description>Chatting room</description>

    <properties>
        <java.version>14</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-autoconfigure</artifactId>
            <version>2.3.3.RELEASE</version>
        </dependency>
    </dependencies>

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

</project>

What i tried:

  1. editing the settings.xml file according to this thread Could not transfer artifact org.apache.maven.plugins:maven-surefire-plugin:pom:2.7.1 from/to central (http://repo1.maven.org/maven2)
  2. deleting .m2 folder in maven
  3. Invalidate caches and restart

I have seen a lot of stackoverflow posts but sadly none of them seem to work. How to resolve this ? Thanks.

3
So you are behind a proxy and using http instead of https cause central is https only.khmarbaise
Clicking that link brought up the file in question in the browser; therefore, it's your network configuration.chrylis -cautiouslyoptimistic-
I am having the same error .. :(sean717

3 Answers

1
votes

Since January 15, 2020 maven central no longer supports HTTP, in favor of HTTPS. Consequently, spring repositories switched to HTTPS as well

Check this link for setting proxies for maven build.

Restart your Intellij

0
votes

Please create a file as "settings.xml" under "C:\Users<your_named_folder>.m2". Then put the followings on "settings.xml". Save it. Then delete everything from ".m2" folder and build the project by "mvn clean install" command. It should work.

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      https://maven.apache.org/xsd/settings-1.0.0.xsd">
  <mirrors>
    <mirror>
      <id>anupam.com</id>
      <name>anupam</name>
      <url>https://repo.maven.apache.org/maven2/</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>
</settings>
0
votes

The advise https://stackoverflow.com/a/63533677/8512173 helped me. I only started use anupam.com in settings.xml