Bean validation in Spring Rest using @Valid

Bean validation in Spring Rest using @Valid: Bean validation is important to validate the input bean received in the spring restful requestbody. And also default error messages may not be properly understandable by our consumers, so validating the bean and responding the proper readable message to our consumers makes our spring restful webservice better.   How are we going to […]

61 total views, no views today

» Read more

Entity to DTO using Model Mapper in Spring Restful Web services

Entity to DTO using Model Mapper in Spring Restful Web services: In spring restful webservices we can not directly expose our entity pojo classes as json responses as it has lot of issues like security/unwanted data’s exposure etc. Data Transfer Object (DTO) is a design pattern which actually resolves this issue. I am going to do these sample in spring […]

69 total views, no views today

» Read more

[Resolved] Spring boot JWT Filter called twice

[Resolved] Spring boot JWT Filter called twice: Recently when I was integrating JWT Filter and Simple CORS filter in my spring boot project, I observed that both the filters are called twice before actually reaching my servlet/rest controller.   After googling, I got this link, As per that, One invocation is by servlet container and the other is by Spring […]

195 total views, no views today

» Read more

10 Things to Know in Spring Boot

10 Things to Know in Spring Boot 1. Spring boot is not a brand new framework like mvc/web/rest/jpa add-ons, it’s just a additional kit from spring to reduce the development headaches with spring framework. 2. Spring boot provides single dependency entry for pom.xml configuration, <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.10.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> Here this downloads all the […]

267 total views, no views today

» Read more

Restful Web services with Spring boot Simple Example

Restful Web services with Spring boot Simple Example This post is aimed to give understanding about web service with spring (through spring boot) for beginners.   Steps to Create a simple restful web service: 1. Create a normal class and add @RestController annotation. @RestController public class GreetingController{ }   2. Create a method and add @RequestMapping(“/greeting”) annotation. Here /greeting refers […]

405 total views, no views today

» Read more

Reading ClassPath file in Spring Boot/Core Example

This below program reads the status.txt file from the classpath, that is src/main/resources in the maven projects using classpathloader in spring core/spring boot projects. Classpathloader converts it to inputstream, from inputstream we can convert to bufferedinputstream and read the file contents easily. File Structure: Here we have status.txt file inside the resources folder, and we have only the value 100 […]

354 total views, no views today

» Read more

Scheduler in Spring Boot with 3 Simple Steps Example

Scheduler in Spring Boot with 3 Simple Steps Example: Scheduler in spring boot became very simple and any one create a Cron job or scheduler in spring boot with just 3 steps. Step 1: Enable spring boot for schedules Add¬†@EnableScheduling to your spring boot main class. @SpringBootApplication @EnableScheduling public class SpringBootStarter{ public static void main(String[] args) { SpringApplication.run(SpringBootStarter.class, args); } […]

488 total views, no views today

» Read more

Spring Boot + EhCache Hibernate Working Example

Spring Boot + Ehcache Hibernate Working Example: When I was trying to populate JSON records in my angular app (just 1885 records only), it took around 11 seconds and in angular side I am just populating in the datatable. So I thought to implement ehcache with spring boot to make it faster. After implementing that successfully I am really surprised […]

649 total views, no views today

» Read more

Join two tables using Hibernate in Spring Boot Example

Join two tables using Hibernate in Spring Boot Example: Many enterprise applications whichever using hibernate uses sql queries only for joins still and uses hibernate only for save/update operations. Today we are going to see how to use hibernate to join two tables. We are going to see how to get count(*) using hibernate along with group by function in […]

838 total views, no views today

» Read more

Spring Boot Native Query Example

Spring Boot Native Query Example: In Spring boot, database operations can be performed by implementing CrudRepository<Object, Long> in our @Repository interface. Here¬†Object is our entity class. @Query Annotation: We can execute nativeQueries using @Query annotation. Need to make the nativeQuery boolean to true and provide the native query to value parameter for @Query annotation.   Syntax: @Query(nativeQuery=true, value=”select s.store_name, s.store_url […]

573 total views, no views today

» Read more
1 2