Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not resolve dependencies for spring-web-reactive

I am using the Reactive approach for asynchronous stream processing in my SpringBoot Application.

I have these 6 imports for SpringFramework

import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;
import static org.springframework.web.reactive.function.server.RequestPredicates.*;
import static org.springframework.web.reactive.function.BodyInserters.fromObject;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;

I'm using this Dependency in my pom.xml. But these seems to be last used in 2016 according to Maven central.

<!-- https://mvnrepository.com/artifact/org.springframework/spring-web-reactive -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web-reactive</artifactId>
<version>5.0.0.M2</version>
</dependency>

This is my error upon Maven build

[ERROR] Failed to execute goal on project SpringReactive: Could not resolve dependencies for project com.ayman:SpringReactive:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at org.springframework:spring-web-reactive:jar:5.0.0.M4: Failed to read artifact descriptor for org.springframework:spring-web-reactive:jar:5.0.0.M4: Could not transfer artifact org.springframework:spring-web-reactive:pom:5.0.0.M4 from/to public (https://globalrepositorymy-company'srepository.int/artifactory/public): connect timed out -> [Help 1]

Is this because I am using deprecated packages, or is it because I corrupted packages? Or is it because these dependencies are not available in my companys' repository?

Rest of my 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>

    <groupId>com.ayman</groupId>
    <artifactId>SpringReactive</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>SpringReactive</name>
    <description>Demo project for Spring Boot</description>

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

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

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

        <!-- Reactor-Core -->
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-core</artifactId>
            <version>3.1.8.RELEASE</version>
        </dependency>

        <!-- Spring-data-commons -->
        <dependency>
                <groupId>org.springframework.data</groupId>
                <artifactId>spring-data-commons</artifactId>
                <version>2.0.8.RELEASE</version>
        </dependency>

       <!-- https://mvnrepository.com/artifact/org.springframework/spring-web-reactive -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web-reactive</artifactId>
            <version>5.0.0.M4</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-mongodb -->
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-mongodb</artifactId>
            <version>2.0.8.RELEASE</version>
        </dependency>
    </dependencies>

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


</project>
like image 855
Alex Smith Avatar asked Jul 04 '18 05:07

Alex Smith


1 Answers

spring-web-reactive is the former name of the module, that was changed during the Spring Framework 5.0 milestones. As shown by the link you're mentioning, those artifacts were never available on maven central but only on a Spring artifact repository.

If you take a look at the Spring Boot reference documentation, you'll see that spring-boot-starter-webflux is the dependency to add to your application to pick up spring-webflux, which is the module name for the reactive web support in Spring Framework.

Note that because you've got spring-boot-starter-web already in your application, your application will remain a Spring MVC application if you add the webflux starter, as stated in the reference documentation. There's nothing wrong with that, as Spring MVC supports reactive types in the controller signatures in some cases. It all boils down to what you're trying to achieve here.

like image 73
Brian Clozel Avatar answered Sep 18 '22 02:09

Brian Clozel