DynamoDB with Kotlin and Spring Boot (Part 1) During the last week I implemented my first persistence layer with DynamoDB using Spring Boot and Kotlin. As I stumbled over a couple of obstacles, I decided to summarize what I did and how my final implementation looked like. Dependencies The dependencies are pretty straight forward. I decided to use Spring Data for DynamoDB and […]
Testing @ConfigurationProperties in Spring Boot *** Update *** I updated the example on GitHub to Spring 2.5.X! The latest post on this topic is at https://tuhrig.de/testing-configurationproperties-in-spring-boot-2-5-x. I recently worked on a library for using AWS Kinesis in Spring Boot. As many other libraries, this particular one provided a powerful configuration. To implement the configuration, we used Spring Boot’s @ConfigurationProperties (as […]
Encapsulated modules and clean tests with Spring’s @Configuration Usually we use Spring’s @Configuration to define some special beans. A classic example is the definition of a data source: 1234567 @Beanpublic DataSource dataSource() { DataSource dataSource = new DataSource(); dataSource.setUsername(username); // ... and so on ... return dataSource;} However, we can also use Spring’s @Configuration to build better modules which helps us to writer cleaner tests. Let’s go through an example. An example Let’s assume we have an application which uses domain […]
Saga pattern with Spring Boot and ActiveMQ During the last days, I dug a little bit into the Saga pattern. The Saga pattern is an architectural pattern which provides an alternative approach to big and long running ACID transactions. It takes a business process and breaks it up into small isolated steps – each of them with its own transaction. The overall […]
Spring-Boot boilerplate project with ActiveMQ and AngularJS During the last couple of months, I wrote a lot blog posts about ActiveMQ (JMS), AngularJS and Spring. Most of those blog posts include some small code snippets, but nothing more. That’s why I decided to setup a “boilerplate project” to show how all those different techniques can go hand in hand in a “real […]
Virtual Topics in ActiveMQ A couple of days ago I published a post about the difference between queues, topics and virtual topics. Today I want to share some practical information on how to use virtual topics in ActiveMQ with Spring Boot. Virtual Topics Virtual topics are a combination of topics and queues. Producers will write messages to a topic […]
Using @ConfigurationProperties to separate service and configuration Roughly about two years ago, I wrote an article called “Why using Spring’s @Value annotation is bad“. I described why you should avoid @Value annotations all throughout your code. By using @Value annotations in services, controllers and other Spring components, you will scatter your configuration through the complete application. In the worst case, you will […]
Expression based security with Spring Security Many web apps have a very simple security concept based on user roles. You might have some admin, some common users and maybe some more roles like a moderator or a super-user. Such a role concept can be easily implemented with Spring Security. For example, you could secure your app based on routes which are […]
Inject mocks with Spring’s @ContextConfiguration One of the biggest strengths of Spring is its ability to make your code testable. By using dependency injection and inversion of control, the Spring context defines which objects will be wired into your beans. This makes it easy to wire services, repositories or what ever you like. But how to wire mocks in your […]
A mocked Spring security configuration for testing Spring security is great! It gives you the possibility to secure your app and to create a login with a few simple lines of code. However, it could also become annoying during development, when you have to log yourself in again and again. So why not create a mocked Spring authentication for development and testing? […]