Proper JMS conversion to POJOs

While looking into Azure Service bus with Spring Boot, I stumbled upon a nasty stacktrace caused by an IllegalArgumentException: java.lang.IllegalArgumentException: Property name must not be null So what is going on here? Setup I configured a queue persons on Azure service bus and in my spring boot application I defined a QueueListener using the @JmsListener annotation @Component public class PersonQueueListener { private static final String QUEUENAME="persons"; @JmsListener(destination = QUEUENAME) public void receiveMessage(Person person) throws JsonProcessingException { log....

June 14, 2022 · 3 min

Custom property naming strategy with Jackson

For a pet project of mine, I’m consuming a REST API. Unfortunately it’s probably not written with Spring (Boot), as the body of requests and response are not according to what you’re used to, UpperCamelCase instead of lowerCamelCase. {"SessionKey":"7d38ec29-d1f3-42e9-b35f-91b505bf3206", "Status":"UpdatesComplete" } At first, I thought I could solve it with a @JsonProperty("...") annotation on every field, but there are so many of them :o This can easily be fixed with the property naming class annotation:...

August 11, 2019 · 1 min

Spring boot without a web container

I really like spring boot a lot - just throw in some dependencies and BAM it’s configured right out of the box. For a pet project of mine, I’m consuming a REST API. So I included the spring-boot-starter-web artificact. Not so surprisingly, the logs showed Tomcat was booting. In this particular project, I don’t need tomcat or any other web container for that matter. So how to exclude this? My first guess was the application properties, but there was nothing to turn the web container on or off....

July 31, 2019 · 1 min

How to check if a row with a specific column value exists in Spring Data

Spring Data has a great declarative way of defining queries, called derived queries. Suppose you have a Person class with an email field. Then you can define the following method in a Repository interface: public interface PersonRepository extends JpaRepository<Person,Long>{ List<Person> findByEmail(String email); } Spring derives the query based on the method name, in this case a query to retrieve all persons with a given value for the email field. As you can see, the method returns a List....

June 11, 2019 · 2 min

Version endpoint in Spring Boot

When generating your Spring Boot project using Spring Initializr, you already have the spring-boot-maven-plugin plugin in your Maven pom.xmlfile. Generating build info is done by adding the build-info goal. This results in a /META-INF/build-info.properties file in your resulting package. By default this contains group id, artifact, buildtime and version of the project. Off course you can add additional properties in the additionalProperties element. Just like you define properties in any Maven section....

February 5, 2019 · 2 min