Can Someone please help me. I'm facing the issue has title of this post and don't know how to resolve it. So, this all my classes below. I've got an 404 not found error while I'm calling this resource http://localhost:9000/api/v1/users/create-user.

package com.cnmci.enrollmentservice.handlers;
@Component
public class UserHandler {
    private final UserRepository userRepository;
    private final UserMapper userMapper;

    public UserHandler(UserRepository userRepository, UserMapper userMapper) {
        this.userRepository = userRepository;
        this.userMapper = userMapper;
    }

    public Mono<ServerResponse> createUser(ServerRequest serverRequest) {
        return serverRequest.bodyToMono(UserDto.class)
                //.doOnNext(userDto -> log.info("Incoming user informations are : {} ", userDto))
                .map(userMapper::fromUserDto)
                .flatMap(mappedUser -> {
                    mappedUser.setCreationDate(new Date().toString());
                    return userRepository.save(mappedUser);
                })
                .map(userMapper::fromUser)
                .flatMap(ServerResponse.status(HttpStatus.CREATED)::bodyValue)
                .log();
    }

    public Mono<ServerResponse> retrieveUser(ServerRequest serverRequest) {
        var userId = serverRequest.pathVariable("userId");

        if (userId.isEmpty()) {
            return Mono.error(new RuntimeException("Incoming Id cannot be null or empty"));
        }

        UserDto foundUser = userRepository.findById(userId)
                .map(userMapper::fromUser).block();

        if (foundUser == null) {
            return ServerResponse.status(HttpStatus.OK)
                    .contentType(MediaType.APPLICATION_JSON)
                    .body(Mono.empty(), UserDto.class)
                    .log();
        }

        return ServerResponse.status(HttpStatus.OK)
                .contentType(MediaType.APPLICATION_JSON)
                .body(foundUser, UserDto.class)
                .log();
    }

    public Mono<ServerResponse> retrieveAllUsers(ServerRequest serverRequest) {
        return ServerResponse.status(HttpStatus.OK)
                .contentType(MediaType.APPLICATION_JSON)
                .body(userRepository.findAll()
                        .map(userMapper::fromUser), UserDto.class)
                .log();
    }

    public Mono<ServerResponse> deleteUser(ServerRequest serverRequest) {
        var userId = serverRequest.pathVariable("userId");

        if (userId.isEmpty()) {
            return Mono.error(new RuntimeException("Incoming Id cannot be null or empty"));
        }

        return userRepository.findById(userId)
                .flatMap(userRepository::delete)
                .then(ServerResponse.status(HttpStatus.NO_CONTENT).build())
                .log();
    }
}
package com.cnmci.enrollmentservice.router;

@Configuration
public class RouterConfiguration {
    private final UserHandler userHandler;
    private final ArtisanHandler artisanHandler;

    public RouterConfiguration(UserHandler userHandler, ArtisanHandler artisanHandler) {
        this.userHandler = userHandler;
        this.artisanHandler = artisanHandler;
    }

    @Bean
    public RouterFunction<ServerResponse> routerFunction() {
        return route()
                .nest(path("/api/v1/users"), builder ->
                        builder.POST("/create-user", accept(MediaType.APPLICATION_JSON), userHandler::createUser)
                                .GET("/retrieve-user/{userId}", accept(MediaType.APPLICATION_JSON), userHandler::retrieveUser)
                                .GET("/retrieve-users", accept(MediaType.APPLICATION_JSON), userHandler::retrieveAllUsers)
                                .DELETE("/delete-user/{userId}", accept(MediaType.APPLICATION_JSON), userHandler::deleteUser))
                .nest(path("/api/v1/artisans/"), builder -> builder.POST("create-artisan", accept(MediaType.APPLICATION_JSON), artisanHandler::createArtisan))
                .build();

    }
}

and finally this is my pom.xml file content

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-r2dbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-hateoas</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mapstruct</groupId>
            <artifactId>mapstruct</artifactId>
            <version>${org.mapstruct.version}</version>
        </dependency>
        <dependency>
            <groupId>org.mapstruct</groupId>
            <artifactId>mapstruct-processor</artifactId>
            <version>${org.mapstruct.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <scope>annotationProcessor</scope>
        </dependency>
        <dependency>
            <groupId>io.asyncer</groupId>
            <artifactId>r2dbc-mysql</artifactId>
            <version>1.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-mysql</artifactId>
        </dependency>
    </dependencies>

Comment From: bclozel

Thanks for getting in touch, but it feels like this is a question that would be better suited to StackOverflow. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug. You will also find some advice on how to get help in this wiki page.