Home > other >  Why maven trying to find springboot dependencies in my remote repository And How I change it?
Why maven trying to find springboot dependencies in my remote repository And How I change it?

Time:02-05

This is my first question, sorry if there are any mistakes in the question format.

I want to deploy libraries from my remote github repository. At the end, I actually did it. The remote repository is working for my libraries but now org.springframework.boot:spring-boot-starter-parent:pom:2.5.0 is giving an "failed to transfer from" when I sync the maven project.


org.springframework.boot:spring-boot-starter-parent:pom:2.5.0 failed to transfer from https://maven.pkg.github.com/ifsygn/ifsygn-maven-repo during a previous attempt. 
This failure was cached in the local repository and resolution is not reattempted until the update interval of github has elapsed or updates are forced. 
Original error: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.5.0 from/to github (https://maven.pkg.github.com/ifsygn/ifsygn-maven-repo): 
authentication failed for https://maven.pkg.github.com/ifsygn/ifsygn-maven-repo/org/springframework/boot/spring-boot-starter-parent/2.5.0/spring-boot-starter-parent-2.5.0.pom, status: 401 Unauthorized

Try to run Maven import with -U flag (force update snapshots)

maven version: apache-maven-3.8.7


After adding the remote repository, the problem started.

now pom.xml is...

...

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.0</version>
        <relativePath>/pom.xml</relativePath> <!-- lookup parent from repository -->
    </parent>

    <groupId>org.csystem</groupId>
    <artifactId>CommandPromptApp</artifactId>
    <version>1.0.0</version>
    <description>Command Prompt App</description>

    <properties>
        <java.version>11</java.version>
    </properties>


    <repositories>

                <!-- my remote repository-->
        <repository>
            <id>ifsygn-maven-repo</id>
            <name>github maven repo</name>
            <url>https://raw.github.com/ifsygn/ifsygn-maven-repo/main</url>
        </repository>

    </repositories>

    <dependencies>

        <dependency>
            <groupId>org.csystem</groupId>
            <artifactId>org-csystem-util-console</artifactId>
            <version>4.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.csystem</groupId>
            <artifactId>org-csystem-util-commandprompt</artifactId>
            <version>4.0.0</version>
        </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>
    </dependencies>

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


</project>

Also I add something to settings.xml because of after maven 3.8.1 something is changed and gave a blocked mirror error. But I solved that. Now just I need your help with the problem above. I would be very happy if anyone could help.

CodePudding user response:

From your error message, the problem is

status: 401 Unauthorized

which means that you have probably not set the credentials for contacting github correctly.

CodePudding user response:

you should edit settings.xml(username, password, repository url) in your /.m2 directory

/Users/username/.m2/

CodePudding user response:

After trying many solutions, I solved the problem in a very strange way. I deleted all mirrors, repositories, and profiles in settings.xml. I was going to completely edit the settings.xml for authentication. After deletion, I tried and it worked. The project builds successfully.

To test I deleted /Users/username/.m2/repository. It downloads all repositories, the ones remote too.


I deleted too .m2\settings.xml

Now my apache-maven-3.8.7\conf\settings.xml is just like this...

<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
          
</settings>
  • Related