Category Archives: Spring Boot

Spring Boot – Create REST API Basic (Hello World)

Hey guys 👋In the last tutorial we have been already learn about create new spring boot application. In this tutorial, we will learn how to create REST API basic in spring boot. Spring Boot – Create REST API Basic (Hello World) First, create new package or folder with name “controller”. Second, create new java class with name “”. After that… Read More »

WebFlux Pagination For Reactive Spring Data

In this example I’m trying to create wrapper for pagination with reactive code in spring 5. I have created simple rest endpoint for finding all entities using spring web-flux and spring data reactive mongoDB with pagination. WebFlux Pagination For Reactive Spring Data In Spring Data 1.0, we have PagingAndSortingRepository which inherits from CrudRepository. In reactive Spring Data, we… Read More »

What Is Spring Boot?

Spring Boot is a framework created by Pivotal. Spring Boot is very popular in java community because this framework can make it easy to create stand-alone web application. This framework is designed to simplify the bootstrapping and development of a new Spring application. Developers just need a very little Spring configuration to run web application, because the framework takes an… Read More »

Spring RestTemplate With Cookie In Header

Spring rest template hit endpoint with cookie in header can be like this: RestTemplate restTemplate = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); headers.setAccept(Collections.singletonList(MediaType.ALL)); headers.add(“Cookie”, “ID=SPRING-JAVA”); HttpEntity entity = new HttpEntity<>(headers); ResponseEntity response = “”, HttpMethod.GET, entity, String.class); Spring RestTemplate With Cookie In Header In this example i’m using java 8 and spring boot version 1.5.8 with… Read More »

Spring Data MongoDB LIKE Query Insensitive Case ‘%%’

With spring data mongoDB you can do “LIKE QUERY” like example below. Query query = new Query(); query.addCriteria(Criteria.where(“name”).regex(“yourString”, “i”)); mongoTemplate.find(query, CodingExample.class) Spring Data MongoDB LIKE Query Insensitive Case Spring Data MongoDB The Spring Data MongoDB project provides integration with the MongoDB document database. Key functional areas of Spring Data MongoDB are a POJO centric model for interacting with… Read More »

AsyncRequestTimeoutException in Spring Boot

If you using asynchronous programming with observable streams in spring boot, i suggest you to setup async request timeout because default async request timeout in spring boot 2.0 is 10 second. You will got an exception (AsyncRequestTimeoutException) when request is more than 10 second. AsyncRequestTimeout My suggestion is 60s or 120s (s mean second) : spring.mvc.async.request-timeout=60s That is how to… Read More »

REST API Return Image With Spring

How to create rest controller for return image file? Here is the code for create image rest API with spring: @GetMapping( value = “/img”, produces = {MediaType.IMAGE_JPEG_VALUE, MediaType.IMAGE_GIF_VALUE, MediaType.IMAGE_PNG_VALUE}) public ResponseEntity getImageAsResource() { HttpHeaders headers = new HttpHeaders(); String home = System.getProperty(“user.home”); File f = new File(home + File.separator + “Desktop” + File.separator + “image.jpg”); Resource resource =… Read More »

IntelliJ IDEA – Create Spring Boot Application

This is how to create spring boot application from IntelliJ IDEA. 1. On the top IDE menu choose “File” -> “New” -> “Project…” 2. Setup JDK 3. Fill project details like group artifact type of build tools (maven or gradle) programming language (java, kotlin, groovy) packaging (jar or war) file application name application description package (com.example.module-name) 4. Choose… Read More »