Understanding @DependsOn

In Spring framework, beans are initialized in some particular order and their life cycle is maintained by Spring container. But we can still customized it with one of the Spring’s annotation @DependsOn. Lets’s Code Configuration: – Below code snippets are from the earlier repo which was used for @Conditional blog. Lets say, we have requirement of loading one bean only after another bean gets loaded … Continue reading Understanding @DependsOn

@Conditional… in Spring Boot

While building Spring Boot app, we could fall in one use case where we need to load some of our beans conditionally i.e. Loading that bean based on another bean. Spring 4.0 has introduced a new annotation¬†@Conditional that allows us to use either pre-defined or custom conditions which will be applied to bean in application context. In this blog, we will introduce you with some … Continue reading @Conditional… in Spring Boot

Intro to Spring Cloud Contract

Everyone is into micro services now a days. Deploying new services into today’s distributed system requires another level of confidence. Spring cloud contract provides support for Consumer Driven Contracts (CDC) and service schemas in Spring applications. It enables Consumer Driven Contract (CDC) development of spring applications and makes sure that the new feature(i.e. API) that we are going to add in our existing application, should … Continue reading Intro to Spring Cloud Contract

@ConfigurationProperties in Spring Boot

There are number of ways you can externalize your configuration properties in application so that you can work in different environment. You can use properties files, YAML files, environment variables, and command-line arguments to externalize configuration. Property values can be injected directly into your beans by using the @Valueannotation but that is very tedious and cumbersome process , especially if you are working with multiple … Continue reading @ConfigurationProperties in Spring Boot

Spring Profiles

Spring profile is a way to achieve environment specific execution of class or code i.e. Spring Profiles provide a way to segregate parts of your application configuration and make it be available only in certain environments.  If you want to run your piece of code or initialize any specific bean in any certain environment, Spring Profiles is the option. Implementation Any class marked with @Component … Continue reading Spring Profiles