1

I'm trying to push my code but I have this error and I don't undertand what I'm missing to add or if I'm using some version wrong.

This is my error:

jar:0.0.1-SNAPSHOT: Could not find artifact org.springframework:spring-test:jar:5.1.4.BUILD-SNAPSHOT in java-net-repo (https://maven.java.net/content/repositories/public/)

This is my pom:

<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.1.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.martinrico.berserker_v0</groupId>
<artifactId>berserker_v0</artifactId>
<version>4.1.1.RELEASE</version>
<name>berserker_v0</name>
<description>Demo project for Spring Boot</description>

<properties>
    <java.version>1.8</java.version>
    <jjwt.version>0.9.0</jjwt.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>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>

    <!-- For Working with Json Web Tokens (JWT) -->
    <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt</artifactId>
        <version>${jjwt.version}</version>
    </dependency>

    <!-- For Java 8 Date/Time Support -->
    <dependency>
        <groupId>com.fasterxml.jackson.datatype</groupId>
        <artifactId>jackson-datatype-jsr310</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>5.1.4.BUILD-SNAPSHOT</version>
        <scope>compile</scope>
    </dependency>

</dependencies>

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

Any help would be appreciated, thanks in advance!

  • You should look at this post: https://stackoverflow.com/a/37276264/3780625 – Maxouille Mar 17 '19 at 19:24
  • `spring-test` is already part of `spring-boot-starter-test` and you should not add this again as seperate dependency. What is even worse you are starting to mix different jars of different Spring versions. Spring Boot 2.0 uses Spring 5.0 and now you are adding a 5.1 jar. That is trouble waiting to happen. – M. Deinum Mar 18 '19 at 06:45

1 Answers1

2

This one is a current SNAPSHOT dependency which is not released to Maven Central:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-test</artifactId>
    <version>5.1.4.BUILD-SNAPSHOT</version>
    <scope>compile</scope>
</dependency>

If you really need this (be aware of changes during every Maven run as this is the character of snapshots), you have to use additionally Spring's Snapshot repository:

<repositories>
    <repository> 
        <id>repository.spring.snapshot</id> 
        <name>Spring Snapshot Repository</name> 
        <url>http://repo.spring.io/snapshot</url> 
    </repository>
</repositories>

See the dependency also in the repo path itself.

mle
  • 2,466
  • 1
  • 19
  • 25
  • 1
    You should not use SNAPSHOT repos you can simply use Central repository cause Spring Boot is available there... – khmarbaise Mar 18 '19 at 05:44