Augmenting Spring Data REST with Additional Endpoints

Spring Data REST combines the features of Spring Data with Spring HATEOAS to make it easy to build hypermedia-driven REST APIs on top of Spring Data repositories. The basic functionality provided out of the box creates and exposes simple REST endpoints for performing CRUD operations on Spring Data repositories. For a lot of use cases, this is entirely enough functionality to meet your needs. In other cases, you need to extend the REST API to include additional functionality that isn’t provided by Spring Data REST and it can be difficult to determine exactly how to do this....

May 19, 2021 · 3 min · Kevin Sookocheff

Understanding Spring's Environment Abstraction

When working with Spring Boot, some auto-configuration can happen seemingly by magic. For example, in a traditional Spring application with Java-based configuration, you might configure an H2 database using the following block of code to set the type of the database and run some scripts to initialize it: @Bean public DataSource dataSource() { return new EmbeddedDataSourceBuilder() .setType(H2) .addScript("taco_schema.sql") .addScripts("user_data.sql", "ingredient_data.sql") .build(); } With Spring Boot, you can remove this entire block of code and use auto-configuration....

May 27, 2020 · 3 min · Kevin Sookocheff

Building a Modern Java Web App with Spring Boot

I’m a fan of Java. If you haven’t given it a chance in a while, you may not have noticed that, Java has quietly been adopting some of the best practices that make dynamic and functional languages so appealing, without sacrificing the many hundred person-years of effort that have made Java and the JVM a world-class development environment. Java is still one the world’s most popular programming languages with roughly 9 million programmers using Java....

May 20, 2020 · 10 min · Kevin Sookocheff

Inversion of Control, Dependency Injection, and the Spring IoC Container

Inversion of Control (IoC), also known as Dependency Injection (DI), allows an object to define their dependencies as constructor arguments (strictly speaking, you can set these dependencies as properties, but the examples I will use today are constructor-based). This is the inverse of the object itself controlling the instantiation or location of its dependencies, hence the name Inversion of Control. Let’s look at an example from Stackoverflow using a text editor with a spell checking component:...

May 14, 2020 · 5 min · Kevin Sookocheff