Posts by Willem Cheizoo

Spicy Spring: Splitting Configuration and make Properties immutable

Posted on by  
Willem Cheizoo

A Spring Boot application typically consists of several components handling the business functionality and probably some configuration to configure all these components. This configuration consists of defining some properties, setting up some beans with the right conditions and dependencies and wrapping it all together into a class structure. Nevertheless, the configuration of our Spring Boot application is also code. Let’s threat is as code.

In this blog we will se how we can improve our Spring Boot Configuration by splitting up the configuration from the properties and how this effects the design principles.

Continue reading →

Effectively use Mapstruct and Lombok's builder

Posted on by  
Willem Cheizoo

Since Mapstruct version 1.3.0.Final is out, we are able to better integrate with Lombok Builder pattern. Mapstruct is a library that takes away a lot of boilerplate code for mapping between POJO’s. With Mapstruct there is no need for implementing the real mapping itself.

With Lombok we can use a Builder pattern and mark an object as a Value(Object). It will result in an immutable object. This blog post shows how we can use Mapstruct to use the Builder pattern of Lombok.

Continue reading →

Release NPM package with git-flow

Posted on by  
Willem Cheizoo

Having an NPM package in an enterprise environment and wanting to release that package using the git-flow model? Then using the [node-generate-release](https://ift.tt/28QYo7d) can be very helpful. This blog shows how to execute an integrated git flow release from your NPM package, even if your master and develop branches are protected.

Let’s assume we have all changes in the develop branch and we would like to create a release with all the current changes in develop. With the git-flow release the result will be that all changes will be merged into master and a tag for the release version is created with correct version. Before we can finish the release the correct version in NPM package.json needs to be set. This can all be nicely done with node-generate-release plugin.

Continue reading →

Make Git files executable

Posted on by  
Willem Cheizoo

You can check files with correct permissions into Git to be able to run them on the continuous integration server right after checkout. Setting the right properties in the git-index will force Git to checkout the file and set the right file permissions. Set the core.fileMode in the git configuration to false. The means: Do not ignore the file mode. Then update the git-index with --chmod for your file, commit and push the file to the repository.

Continue reading →

Handling YAML format in your REST with Spring Boot

Posted on by  
Willem Cheizoo

In general a REST service serves JSON document formats. In Spring Boot it is even the standard without having to configure anything. Over HTTP we have the ability to send a Content-Type as header to instruct the server to return a certain document format (Mime type). Besides handling JSON, XML is another common document format. But what if we want to serve or read a YAML document format? This tutorial provides the required steps to be able to handle objects in YAML format. To be able to send a YAML Content-Type with the header, and to be able to serialize and deserialize with the existing ObjectMappers of Jackson. This tutorial will use Spring Boot, Jackson and a YAML dataformat extension library for Jackson.

First we need to add the YAML Jackson extension to our Gradle build file.

Continue reading →

Devoxx4Kids: Technologie is cool

Posted on by  
Willem Cheizoo

Het is zaterdagochtend: terwijl de meeste developers uitslapen en genieten van hun vrije dag zijn een aantal JDriven collega’s al vroeg in de veren. Op naar Arnhem om kinderen in de leeftijd van 10 tot 14 jaar kennis te laten maken met programmeren. Een groep van 45 kinderen volgen drie verschillende lessen:

  1. programmeren in Scratch,

  2. python programmeren met Minecraft,

  3. zelf je mBot besturen.

Continue reading →

Integrate Angular in Spring Boot with Gradle

Posted on by  
Willem Cheizoo

Having a Angular HTML5 single page application and a Spring Boot application, we would like to serve the complete Angular app from Spring Boot. This blog shows you a couple simple steps to get everything up and running: run NPM from Gradle, integrate the Gradle frontend build in the main build and support HTML5 mode in the ResourceHandler of Spring Boot.

Create a subdirectory called frontend with the frontend code and build scripts (webpack, npm). Let's assume our npm start and npm run watch output to the /frontend/dist/ directory. First we need to make sure the frontend code is build when we run gradle build on our project. We can use the plugin gradle-node-plugin for this. Go ahead and create a /frontend/build.gradle file.

Continue reading →

Spring Batch and Feign OAuth2 RequestInterceptor

Posted on by  
Willem Cheizoo

We have a microservice architecture with one of the microservices having a Spring Batch job which processes a CSV file and calling another microservice. Both microservices are OAuth2 protected ResourceServers. When we call the first microservice, a batch job is started and we want the Authorization header to be passed to the second microservice. The solution can be defined as: In a Feign RequestInterceptor, grab the current OAuth access_token and pass it on the the RequestTemplate with Hystrix running in SEMAPHORE execution isolation strategy

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@EnableResourceServer
@EnableOAuth2Client
public class MyApplication {

  public static void main(String[] args) {
    SpringApplication.run(MyApplication .class, args);
  }
}

Continue reading →

shadow-left