23
votes

I decided to update my spring-boot-starter-parent to version 2.0.0.M1 in order to use it with Spring Core 5.0.0.RC1.

But, i am having issues downloading the dependency from the Spring milestone repository.

My pom.xml

<?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>

<groupId>com.test.testapplication</groupId>
<artifactId>application</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.0.M1</version>
</parent>

<repositories>
    <repository>
        <id>repository.spring.milestone</id>
        <name>Spring Milestone Repository</name>
        <url>http://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.test.testplugin</groupId>
            <artifactId>plugin</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.test.testutils</groupId>
            <artifactId>utils</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
        </dependency>
    </dependencies>
</dependencyManagement>

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

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>

I have a "clean sheat" .m2 settings.xml, and i have cleaned my local repository, and made sure i can connect to the spring milestone repository.

[INFO] ------------------------------------------------------------------------
[INFO] Building application 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-maven-plugin/2.0.0.M1/spring-boot-maven-plugin-2.0.0.M1.pom
[WARNING] The POM for org.springframework.boot:spring-boot-maven-plugin:jar:2.0.0.M1 is missing, no dependency information available
Downloading: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-maven-plugin/2.0.0.M1/spring-boot-maven-plugin-2.0.0.M1.jar
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
.
.
.

[INFO] plugin ............................................. SUCCESS [  0.327 s]
[INFO] application ........................................ FAILURE [  0.881 s]
[INFO] webapp ............................................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
.
.
.
.
.

[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.springframework.boot:spring-boot-maven-plugin:2.0.0.M1 or one of its dependencies could not be resolved: Could not find artifact org.springframework.boot:spring-boot-maven-plugin:jar:2.0.0.M1 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
8

8 Answers

25
votes

Add Spring Plugin Release Repo to Plugin-Repositories. So that it can find the spring-boot-maven-plugin-2.0.0.M1.jar. I have seen that it contains in that repo

Add the below lines under <project> tag as like:

<project>
<!------ others lines -->
    <pluginRepositories>
        <pluginRepository>
            <id>repository.spring.release</id>
            <name>Spring GA Repository</name>
            <url>https://repo.spring.io/plugins-release/</url>
        </pluginRepository>
    </pluginRepositories>
</project>

EDIT

As I have no com.test.testplugin, I have checked with the followings. Please, remove the <dependencyManagement> and put <dependencies> under <project>. Final pom.xml looks like:

<?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>

    <groupId>com.test.testapplication</groupId>
    <artifactId>application</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.M1</version>
    </parent>

    <pluginRepositories>
        <pluginRepository>
            <id>repository.spring.release</id>
            <name>Spring GA Repository</name>
            <url>https://repo.spring.io/plugins-release/</url>
        </pluginRepository>
    </pluginRepositories>

    <repositories>
        <repository>
            <id>repository.spring.milestone</id>
            <name>Spring Milestone Repository</name>
            <url>https://repo.spring.io/milestone</url>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
        </dependency>
    </dependencies>

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

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
</project>
8
votes

To use spring-boot milestone versions, add following to pom.xml, between <project></project>:

<repositories>
    <!-- for spring milestone -->
    <repository>
        <id>spring.milestone</id>
        <url>http://repo.spring.io/milestone</url>
    </repository>
</repositories>
<pluginRepositories>
    <!-- for spring milestone -->
    <pluginRepository>
        <id>spring.milestone</id>
        <url>http://repo.spring.io/milestone</url>
    </pluginRepository>
</pluginRepositories>
5
votes
For 

  `<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.M7</version>
    </parent>`

Putting below repositories tags in pom.xml , it helped me building project .

<repositories>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>repository.springframework.maven.release</id>
        <name>Spring Framework Maven Release Repository</name>
        <url>http://maven.springframework.org/milestone/</url>
    </repository>
    <repository>
        <id>org.springframework</id>
        <url> http://maven.springframework.org/snapshot</url>
    </repository>
    <repository>
        <id>spring-milestone</id>
        <name>Spring Maven MILESTONE Repository</name>
        <url>http://repo.spring.io/libs-milestone</url>
    </repository>
    <repository>
        <id>spring-release</id>
        <name>Spring Maven RELEASE Repository</name>
        <url>http://repo.spring.io/libs-release</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>
0
votes

Add the following into your pom.xml file.

 <repositories>
    <repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

<pluginRepositories>
    <pluginRepository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

I suggest you update the Spring Boot version to the latest to get newest dependencies, currently it is 2.0.0.M6 which includes Spring 5.0.1.RELEASE in its dependencies management.

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.0.M6</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

Or generate a new Spring Boot 2.0 based project from Spring Initializer, all dependencies will be resolved.

0
votes

I didn't have a "clean sheet" settings.xml because I have a personal mirror URL in place. The only way to fix this issue was to include @Hantsy answer in my settings.xml instead of the pom.xml

0
votes

If you are in China, you can fix this problem by modifying the settings.xml file like this:

<mirror>
    <id>nexus-aliyun</id>
    <mirrorOf>*</mirrorOf>
    <name>Nexus aliyun</name>
    <url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>

settings.xml path of mine:C:\Program Files\apache-maven-3.6.0\conf\settings.xml

0
votes

The question is bit old, but I am updating here hoping that it might help someone.

In my case, work offline has been checked and hence I was getting error.

Here is the fix I have made. in Mac, navigate to IntelliJ menu and select preferences or short cut key(Command + ,).

Search maven and select. then uncheck work offline if it is checked already.

enter image description here

0
votes

to fix this, try to click the reimport all maven projects button: enter image description here: