Skip to content

The server time zone value ‘CEST’ is unrecognized or represents more than one time zone.

This was a particularly challenging issue that I came up against recently. I’m still not entirely sure of the exact cause, other than many people have already suggested that it is a bug with certain versions of the mysql-connector library. Although I did try using…

Continue reading The server time zone value ‘CEST’ is unrecognized or represents more than one time zone.

How to configure HTTP Basic authentication for Swagger 2 and Spring 2

This post will explain how to configure Spring Boot 2 to access Swagger 2 using HTTP Basic authorization. Requirements Spring Boot 2.0.4.RELEASE Swagger 2.9.2 Create the REST controller import com.server.common.model.Menu; import com.server.dataservice.service.MenuService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; @RestController(“menus”) public…

Continue reading How to configure HTTP Basic authentication for Swagger 2 and Spring 2

Basic Elastic Search Java API CRUD operation example

This guide assumes you have already setup the Elastic Search API with your Java application. The following examples use a ‘Part’ entity: public class Part { private String elasticSearchId; @SerializedName(“PartId”) @Expose public String partId; @SerializedName(“PartNumber”) @Expose public String partNumber; @SerializedName(“PartDescription”) […] Indexing a Part document:…

Continue reading Basic Elastic Search Java API CRUD operation example

Spring Boot multi-thread scheduling

Spring Boot provides impressive scheduling functionality out-of-the-box. To install it all you need to do is include the Spring Boot Starter dependency in your Maven project: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> Configuration By default Spring Boot will use just a single thread for all scheduled tasks…

Continue reading Spring Boot multi-thread scheduling

Create OkHttp3 Response for testing

Use a variation of the following code to create a Response to test with: private Response createResponse() { HttpUrl mHttpUrl = new HttpUrl.Builder() .scheme(“https”) .host(“example.com”) .build(); Request mRequest = new Request.Builder() .url(mHttpUrl) .build(); Response.Builder builder = new Response.Builder() .request(mRequest) .protocol(Protocol.HTTP_1_1) .message(“message”) .code(302); return builder.build(); }…

Continue reading Create OkHttp3 Response for testing