I have this following code:
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
@Component
public class GreetingHandler 
    public Mono<ServerResponse> hello(ServerRequest request) {
        return ServerResponse.ok().contentType(MediaType.TEXT_PLAIN)
        .body(BodyInserters.fromValue("Hello Spring!"));
    }
}
I understand this code except what the class Mono does and what are its features. I did a lot of search but it didn't goes straight to the point: what is the class Mono and when to use it?
 
                        
A
Mono<T>is a specializedPublisher<T>that emits at most one item and then (optionally) terminates with anonCompletesignal or anonErrorsignal. It offers only a subset of the operators that are available for aFlux, and some operators (notably those that combine theMonowith anotherPublisher) switch to aFlux. For example,Mono#concatWith(Publisher)returns aFluxwhileMono#then(Mono)returns anotherMono. Note that you can use aMonoto represent no-value asynchronous processes that only have the concept of completion (similar to a Runnable). To create one, you can use an emptyMono<Void>.Mono and Flux are both reactive streams. They differ in what they express. A Mono is a stream of 0 to 1 element, whereas a Flux is a stream of 0 to N elements.
This difference in the semantics of these two streams is very useful, as for example making a request to an Http server expects to receive 0 or 1 response, it would be inappropriate to use a Flux in this case. On the opposite, computing the result of a mathematical function on an interval expects one result per number in the interval. In this other case, using a Flux is appropriate.
How to use it:
sources: Reactor Java #1 - How to create Mono and Flux?, Mono, an Asynchronous 0-1 Result
it might be helpful: Mono doc