React & Spring Boot

Problem We want to combine Spring Boot with a simple React frontend. Use the React development features but also be able to use the Spring IDE. In the end, everything should be built using Maven and nicely packed into a JAR, just like any other Microservice. Let’s get started. Multi-Module project First we create a…

Datenbank Timeouts | Locks | Isonaltionlevel | Transaktionen

Häufig vergessen, oder nur teilweise gemacht. Timeouts tragen einen wesentlichen Bestandteil zur Stabilität und dem Ressourcenmanagement von Software bei. Insbesondere bei Microservices sollten diese immer richtig eingestellt sein. Timeouts spielen auch eine wesentliche Rolle in Bezug auf Transaktionen, Locks und Isolationslevel. Sollte man zudem den Zugriff auf die Datenbank auch Dritten gewähren, also nicht nur…

Disable @Scheduled timers for test in Spring

Problem As soon we have timers in our project they may cause issues in our integration tests, as they start running in the most undesirable situation. E.g. during the trigger a specific function which would usually be triggered by the timer. Solution In the easiest scenario if it is a in memory Spring test we…

Angular & Spring Boot

Problem We want to combine Spring and Angular use the Angular developing features but also be able to use the Spring IDE, in the end, everything should be build using maven and nicely packed into a JAR.Let’s get started. Overview Less text more code get me to the source. Multi-Module project It may make sense…

Use Session and Request Scope Beans in Tests with Spring

Sometimes it is useful haven the Web Scopes in Unit Tests. Usually Spring just show this very useful error in the Unit Test: Caused by: java.lang.IllegalStateException: No Scope registered for scope ’session‘ at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1120) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1044) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:533) … 28 common frames omitted You can easily have all needed…

Spring Boot Configuration – Properties not loaded

I had recently a very interesting problem using Spring Boot and the automagic concerning the configuration. The Problem org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‚demo.MyApplicationTests‘: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.String demo.MyApplicationTests.url; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder ‚my.url‘ in string value „${my.url}“ at…