@DirtiesContext in Spring

@DirtiesContext is a test annotation which indicates that the  ApplicationContext associated with a test is dirty and should therefore be closed and removed from the context cache. Once the TestContext framework loads an  ApplicationContext  (or WebApplicationContext) for a test, that context is cached and reused for all subsequent tests that declare the same unique context configuration within the same test suite. For example, if TestClassA specifies {“app-config.xml”, “test-config.xml”} for the locations (or value) attribute of @ContextConfiguration, the … Continue reading @DirtiesContext in Spring

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

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