Home » Tag Archives: Spring

Tag Archives: Spring

Using @ResponseStatus for Http Status in Spring

spring-interview-questions-answers

Introduction: In Spring MVC, we can set the status of the HttpResponse in several ways. In this tutorial, we’ll achieve it using the @ResponseStatus annotation. We can use @ResponseStatus to mark a method or an exception class with a status code and reason that should be returned. On invoking the marked handler method or when a specified exception is thrown, ...

Read More »

@Component vs @Repository vs @Service in Spring

spring-interview-questions-answers

Introduction: With Spring’s auto-scanning feature, it automatically detects various beans defined in our application. We usually annotate our beans using one of the available Spring annotations – @Component, @Repository, @Service, @Controller. On detecting the bean, Spring simply registers it into the ApplicationContext. In this quick tutorial, we’ll look at the difference between @Component, @Repository, and, @Service Spring annotations. @Component: We ...

Read More »

Spring Core Annotations

spring-interview-questions-answers

Introduction: Spring annotations present in the org.springframework.beans.factory.annotation and org.springframework.context.annotation packages are commonly known as Spring Core annotations. We can divide them into two broad categories: DI-Related Annotations & Context Configuration Annotations: In this tutorial, we’ll explore all of these Spring Core annotations. DI-Related Annotations: 1. @Autowired: We use @Autowired to mark the dependency which will be injected by the Spring container. ...

Read More »

Spring @Value Annotation

spring-interview-questions-answers

Introduction: Spring @Value annotation is used to inject values into variables and method arguments. We can either read spring environment variables or system variables. It also supports SpEL. In this quick tutorial, we’ll explore how to work with Spring @Value annotation. Setup: Let’s start by first defining a few properties in our app.properties file: user.first.name=Sam user.stocks=50 user.address=California user.preferences=A,B,C products.count={P1: '3', ...

Read More »

Deploy a Spring Boot Application into Tomcat

spring-interview-questions-answers

“I love writing authentication and authorization code.” ~ No Java Developer Ever. Tired of building the same login screens over and over? Try the Okta API for hosted authentication, authorization, and multi-factor auth. Deploying applications is hard. Often you need console access to the server from which you pull the latest code and then manually instantiate into your container. In ...

Read More »

Is Spring Reactive already obsolete? Inversion of Thread Coupling

spring-interview-questions-answers

Beyond Spring’s Dependency Injectiononly solving 1/5 of the Inversion of Control problem, Spring Reactive bases itself on the event loop. While there are other popular event loop driven solutions (NodeJS, Nginx), the single threaded event loop is a pendulum swing in the other direction from thread-per-request (thread pools). With event loops competing against thread-per-request is there not some pattern that ...

Read More »

Build a Microservice Architecture with Spring Boot and Kubernetes

spring-interview-questions-answers

“I love writing authentication and authorization code.” ~ No Java Developer Ever. Tired of building the same login screens over and over? Try the Okta API for hosted authentication, authorization, and multi-factor auth. In this tutorial, you’re going to use Kubernetes to deploy a Spring Boot microservice architecture to Google Cloud, specifically the Google Kubernetes Engine (GKE). You’re also going ...

Read More »

More about Spring Cache Performance

spring-interview-questions-answers

This is a follow up to our last post about Spring’s cache abstraction. As engineers, you gain valuable experience by understanding the internals of some of the tools that you use. Understanding the behaviour of tools helps you become more mature when making design choices.  In this post, we describe a benchmarking experiment and the results which will help you ...

Read More »