Spring Boot

How to Implement JWT Token Based Authentication in Spring Boot Microservices

Java, Spring Boot, Tools
JWT (JSON Web Token) tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. It is highly recommended and used authentication method for REST API & Webservices. Today we are going to see how to implement JWT token based authentication in spring boot microservices to securely communicate and transfer the data's between the client(any client applications, angular/react/vue in modern application world) and server side applications. Though process for Token Based Authentication Spring security is needed for JWT token based authentication Ensure the signup / login REST API accesses are allowed in spring security (or disable these two API's) During signup, save the captured user details in the user table then generate and res
Creating a SOAP web service with Spring Boot

Creating a SOAP web service with Spring Boot

Spring Boot, Web Services
Creating a SOAP web service with Spring Boot Main Application Spring Boot File: [java] package com.ngdeveloper; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class CouponApplication { public static void main(String[] args) { SpringApplication.run(CouponApplication.class, args); } } [/java] pom.xml file: This below pom.xml file contains the plugin to generate the output directory files from the xsd file, so create the pom.xml, xsd file, endpoints then by starting your spring boot application you will be able to find the other required files generated. These are the files will be generated automatically with this heading info, [plain] // // This file was g...

2 ways to refer classpath resource in spring boot projects

Spring Boot
2 ways to refer classpath resource in spring boot projects   Using ClasspathResource [java] import org.springframework.core.io.ClassPathResource; @Bean public XsdSchema mySchema() { return new SimpleXsdSchema(new ClassPathResource("myfile.xsd")); } [/java]   Note: Here myfile.xsd should be located in src/main/resources. Using Resource [java] import org.springframework.core.io.Resource; @Value("classpath:myfile.xsd") private Resource res; @Bean public XsdSchema mySchema() { return new SimpleXsdSchema(res); } [/java]
How to create a Simple RabbitMQ listener in Spring boot ?

How to create a Simple RabbitMQ listener in Spring boot ?

Articles, Spring Boot
How to create a Simple RabbitMQ listener in Spring boot ?   We are going to create a simple rabbitmq listener in the same spring boot project, but general usecase would be to use rabbitmq is between different microservices / different spring boot projects. This is to make a understanding of how to use rabbitmq and what are all things we need to do for a rabbitmq connectivity.   Prerequisite: [xml] <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-amqp</artifactId> </dependency> [/xml] Step 1: Declare a queue name in application.properties file Create (or) automatically enable spring boot project to create the queue when not exist in rabbitmq. Add the below entries in your applicat...

Spring Boot Tutorials

Articles, Spring Boot
Spring Boot Tutorials: 1. Spring Boot - Is it a Brand New Framework ? Spring boot is not a brand new framework, just like mvc/web/rest/jpa add-ons, it's just a additional kit from spring to reduce the development headaches with spring framework. 2. How to configure spring boot in Maven ? 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 dependencies re...

Scheduler in Spring Boot with 3 Simple Steps Example

Frameworks, Spring Boot
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); } } Step 2: Create a cron job component: import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @Component public class CronJobSchedules { private static final Logger log = LoggerFactory.getLogger(CronJobSchedules.class); private static final SimpleDat