December 7, 2023

Spring Boot Microservices – Handling Validations in Spring Boot Application

We already looked at exception handling in a Spring Boot application. The other side of the coin is to validate the incoming data to our application. Lack of validation can lead to bad data in your database. In other words, it can adversely impact downstream processes, business insights and the overall functioning of your application negatively. The key to building a robust Spring Boot microservice is to validate the incoming data. In this post, we are going to look at the process of handling validations in Spring Boot application.

Spring Boot Microservices – Handling Validations in Spring Boot Application Read More

Spring Boot Microservices – Exception Handling in a Spring Boot application

Exception Handling is one of the most important aspects of a production-level Spring Boot Microservice. In the last post Creating REST API using Spring Boot, we had added the functionality to read, create and update records using our application. However, our application was not very robust. In this post, we will look at exception handling in a Spring Boot application.

Spring Boot Microservices – Exception Handling in a Spring Boot application Read More

Spring Auto scanning components

Normally you declare all the beans or components in XML bean configuration file, so that Spring container can detect and register your beans or components. Actually, Spring is able to auto scan, detect and instantiate your beans from pre-defined project package, no more tedious beans declaration in in XML file. Following is a simple Spring project, including a customer service and dao layer. Let’s explore the different between declare components manually and auto components scanning in Spring.

Spring Auto scanning components Read More

Constructor injection type ambiguities in Spring

In Spring framework, when your class contains multiple constructors with same number of arguments, it will always cause the constructor injection argument type ambiguities issue. To fix it, you should always specify the exact data type for constructor, via type attribute. Note: It’s always a good practice to explicitly declared the data type for each constructor argument, to avoid constructor injection type ambiguities issue above.

Constructor injection type ambiguities in Spring Read More

Spring 3 and JSR-330 @Inject and @Named example

Since Spring 3.0, Spring supports for the standard JSR 330: Dependency Injection for Java. In Spring 3 application, you can uses standard: 1 – @Inject instead of Spring’s @Autowired to inject a bean, 2 – @Named instead of Spring’s @Component to declare a bean. Those JSR-330 standard annotations are scanned and retrieved the same way as Spring annotations, the integration just happened automatically, as long as the following jar in your classpath.

Spring 3 and JSR-330 @Inject and @Named example Read More