Search code examples
springmavendependenciespom.xmlspring-boot-actuator

Actuator dependency could not be resolved


I am trying to include spring actuator in my project but when i add the dependency and run maven clean install i am getting an error:

[ERROR] Failed to execute goal on project demo: Could not resolve dependencies for project com.example:demo:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at org.springframework.boot:spring-boot-starter-actuator:jar:2.2.4.RELEASE: Failed to read artifact descriptor for org.springframework.boot:spring-boot-starter-actuator:jar:2.2.4.RELEASE: Could not transfer artifact org.springframework.boot:spring-boot-starter-actuator:pom:2.2.4.RELEASE from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org: Unknown host repo.maven.apache.org -> [Help 1]

See below my pom 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>demo</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

        <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </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>

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

    </dependencies>

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

</project>

Project builds successfully if i remove actuator dependency.

I tried to find the problem, it seemed like a conflict with the version of spring-boot-starter-parent i am using but i could not find the solution.


Solution

  • This question has actually nothing to do with spring or spring boot: Obviously the actuator exists in maven central repository. So its purely a maven issue.

    Unknown host repo.maven.apache.org -> [Help 1]

    This exception means that maven could not contact the central repository and download the actuator jar to the local repository. So I would check the local repository, probably its empty or contains some corrupted artifact.

    1. Make sure you have an internet access
    2. Delete corrupted artifacts from m2 repository
    3. Try to re-run mvn package