Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven compile error - [ERROR] Non-resolvable import POM: Could not transfer artifact

Tags:

maven

New to Maven, possible newbie error.

I am doing the pluralsight introduction to jenkins course. in it we clone the git repository http://github.com/g0t4/jenkins2-course-spring-boot in its subdirectory jenkins2-course-spring-boot\spring-boot-samples\spring-boot-sample-atmosphere there is the following 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
                <!-- Your own application should inherit from spring-boot-starter-parent -->
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-samples</artifactId>
                <version>1.4.0.BUILD-SNAPSHOT</version>
        </parent>
        <artifactId>spring-boot-sample-atmosphere</artifactId>
        <name>Spring Boot Atmosphere Sample</name>
        <description>Spring Boot Atmosphere Sample</description>
        <url>http://projects.spring.io/spring-boot/</url>
        <organization>
                <name>Pivotal Software, Inc.</name>
                <url>http://www.spring.io</url>
        </organization>
        <properties>
                <main.basedir>${basedir}/../..</main.basedir>
        </properties>
        <dependencies>
                <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-web</artifactId>
                </dependency>
                <dependency>
                        <groupId>javax.inject</groupId>
                        <artifactId>javax.inject</artifactId>
                        <version>1</version>
                </dependency>
                <dependency>
                        <groupId>org.atmosphere</groupId>
                        <artifactId>atmosphere-runtime</artifactId>
                        <version>2.2.4</version>
                </dependency>
                <dependency>
                        <groupId>org.webjars</groupId>
                        <artifactId>atmosphere-javascript</artifactId>
                        <version>2.2.3</version>
                </dependency>
                <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-test</artifactId>
                        <scope>test</scope>
                </dependency>
                <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-websocket</artifactId>
                        <scope>test</scope>
                </dependency>
        </dependencies>
        <build>
                <plugins>
                        <plugin>
                                <groupId>org.springframework.boot</groupId>
                                <artifactId>spring-boot-maven-plugin</artifactId>
                        </plugin>
                        <plugin>
                                <groupId>org.jacoco</groupId>
                                <artifactId>jacoco-maven-plugin</artifactId>
                                <version>0.7.7.201606060606</version>
                                <executions>
                                        <execution>
                                                <id>default-prepare-agent</id>
                                                <goals>
                                                        <goal>prepare-agent</goal>
                                                </goals>
                                        </execution>
                                        <execution>
                                                <id>default-report</id>
                                                <phase>prepare-package</phase>
                                                <goals>
                                                        <goal>report</goal>
                                                </goals>
                                        </execution>
                                </executions>
                        </plugin>
                </plugins>
        </build>
</project>

when I try to compile with mvn compile, I get the following build log with errors:

[INFO] Scanning for projects...
Downloading from spring-snapshots: http://repo.spring.io/snapshot/org/springframework/spring-framework-bom/4.3.2.BUILD-SNAPSHOT/maven-metadata.xml
[WARNING] Could not transfer metadata org.springframework:spring-framework-bom:4.3.2.BUILD-SNAPSHOT/maven-metadata.xml from/to spring-snapshots (http://repo.spring.io/snapshot): Authorization failed for http://repo.spring.io/snapshot/org/springframework/spring-framework-bom/4.3.2.BUILD-SNAPSHOT/maven-metadata.xml 403 Forbidden
Downloading from spring-snapshots: http://repo.spring.io/snapshot/org/springframework/spring-framework-bom/4.3.2.BUILD-SNAPSHOT/spring-framework-bom-4.3.2.BUILD-SNAPSHOT.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Non-resolvable import POM: Could not transfer artifact org.springframework:spring-framework-bom:pom:4.3.2.BUILD-SNAPSHOT from/to spring-snapshots (http://repo.spring.io/snapshot): Authorization failed for http://repo.spring.io/snapshot/org/springframework/spring-framework-bom/4.3.2.BUILD-SNAPSHOT/spring-framework-bom-4.3.2.BUILD-SNAPSHOT.pom 403 Forbidden @ org.springframework.boot:spring-boot-dependencies:1.4.0.BUILD-SNAPSHOT, C:\JenkinsTryOut\jenkins2-course-spring-boot\spring-boot-dependencies\pom.xml, line 2058, column 16
[ERROR] 'dependencies.dependency.version' for org.springframework:spring-websocket:jar is missing. @ line 46, column 15
 @
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project org.springframework.boot:spring-boot-sample-atmosphere:1.4.0.BUILD-SNAPSHOT (C:\JenkinsTryOut\jenkins2-course-spring-boot\spring-boot-samples\spring-boot-sample-atmosphere\pom.xml) has 2 errors
[ERROR]     Non-resolvable import POM: Could not transfer artifact org.springframework:spring-framework-bom:pom:4.3.2.BUILD-SNAPSHOT from/to spring-snapshots (http://repo.spring.io/snapshot): Authorization failed for http://repo.spring.io/snapshot/org/springframework/spring-framework-bom/4.3.2.BUILD-SNAPSHOT/spring-framework-bom-4.3.2.BUILD-SNAPSHOT.pom 403 Forbidden @ org.springframework.boot:spring-boot-dependencies:1.4.0.BUILD-SNAPSHOT, C:\JenkinsTryOut\jenkins2-course-spring-boot\spring-boot-dependencies\pom.xml, line 2058, column 16 -> [Help 2]
[ERROR]     'dependencies.dependency.version' for org.springframework:spring-websocket:jar is missing. @ line 46, column 15
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

java version is:

java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)

maven version is:

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\ProgramData\chocolatey\lib\maven\apache-maven-3.6.3\bin\..
Java version: 11.0.1, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-11.0.1
Default locale: en_GB, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
like image 916
Paul Spencer Avatar asked Feb 03 '20 07:02

Paul Spencer


2 Answers

It appears a mixture of not reading the comments and @khmarbaise advice.

in the pom.xml it said:

        <parent>
                <!-- Your own application should inherit from spring-boot-starter-parent -->
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-samples</artifactId>
                <version>1.4.0.BUILD-SNAPSHOT</version>
        </parent>

so when I changed the artifactId to spring-boot-starter-parent, as the comment suggested, and updated the version to 2.2.4.RELEASE as @khmarbaise suggested I got the following parent element of the pom.xml:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.4.RELEASE</version>
    </parent>

and then compiled with mvn compile I was able to successfully compile.

like image 70
Paul Spencer Avatar answered Nov 18 '22 03:11

Paul Spencer


I also started watching the same course, and issued the same problem.
The answer you gave is only partially true. Changing the version to 2.2.4.RELEASE will cause you to face many errors while trying to run mvn test since in the later releases some of the classes are thrown out (ex. org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration). The best solution would be to change artifactId to spring-boot-starter-parent as you said and version to 1.4.0.RELEASE and you'll be able to run all your maven comands without getting errors. So, let's say, fully answer would be:

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.0.RELEASE</version>
</parent>
like image 5
nvkvc Avatar answered Nov 18 '22 03:11

nvkvc