dsplynm
dsplynm

Reputation: 613

Cannot build Spring 4 project with Maven

I am going through this guide:

https://spring.io/guides/gs/rest-service/

I use Maven for building, so I've fetched the pom.xml linked in the official Spring guide:

https://github.com/spring-guides/gs-rest-service/blob/master/initial/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>org.springframework</groupId>
    <artifactId>gs-rest-service</artifactId>
    <version>0.1.0</version>

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

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
    </dependencies>

    <properties>
        <start-class>hello.Application</start-class>
    </properties>

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

    <repositories>
        <repository>
            <id>spring-snapshots</id>
            <url>http://repo.spring.io/libs-snapshot</url>
            <snapshots><enabled>true</enabled></snapshots>
        </repository>
        <repository>
            <id>spring-repo</id>
            <name>Spring Repository</name>
            <url>http://repo.spring.io/release</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>spring-snapshots</id>
            <url>http://repo.spring.io/libs-snapshot</url>
            <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
    </pluginRepositories>
</project>

I get the following error when running mvn install

[ERROR] Error resolving version for plugin org.springframework.boot:spring-boot-maven-build' from the repositories [local (C:\Users\Laszlo_Szucs.m2\repository), spring-snapshots (repo.spring.io/libs-snapshot), central repo.maven.apache.org/maven2)]: Plugin not found in any plugin repository -> [Help 1]

How do I know which version to provide in the pom.xml for this?

Upvotes: 2

Views: 4721

Answers (3)

narinder verma
narinder verma

Reputation: 1

I specified d goals as "spring-boot:run" (without quote) it works for me procedure: right click on myproject>run as >run configurations >click on mavenbuild>goals(specify goal name)>run

Upvotes: 0

user1929513
user1929513

Reputation:

In my case, removing the ~/.m2/repository/org/springframework/boot folder and then cleaning the project resolved the issue. After this issue, I also faced another issue in which STS complained that my maven project was not updated. However, right clicking on the issues in the Markers area and selecting Quick Fix popped up a window which prompted me to update the maven projects. Selecting the projects and clicking the update button in this window resolved the issue.

Upvotes: 0

Batakj
Batakj

Reputation: 12743

Check whether http://repo.spring.io/libs-snapshot is in pom.xml. If not, Add http://repo.spring.io/libs-snapshot to maven repository.

<repository>
    <id>spring-repo</id>
    <name>Spring Repository</name>
    <url>http://repo.spring.io/release</url>
</repository>

And upgrade the maven to 3.0.5 above.

Upvotes: 3

Related Questions