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

Spring Boot Actuator

Actuators are nothing but Spring Boot provided production-ready features to our application. Spring Boot includes a number of additional features to help you monitor and manage your application when you push it to production. You can choose to manage and monitor your application by using HTTP endpoints. Monitoring of application, gathering metrics, understanding traffic becomes trivial with this dependency. The main benefit is actually getting … Continue reading Spring Boot Actuator

@SpringBootApplication Annotation

@SpringBootApplication attribute is used to enable auto-configuration, component scan and to define extra configuration in a single application class. Though the same things can be achieved using following annotations individually @EnableAutoConfiguration: enable Spring Boot’s auto-configuration mechanism automatically configure your Spring application based on the jar dependencies that you have added. For example, if HSQLDBis configured in our classpath, and you have not manually configured any database connection beans, … Continue reading @SpringBootApplication Annotation

@ComponentScan vs @EntityScan

@ComponentScan is used for scanning all your components those are marked as @Controller, @Service, @Repository, @Component etc… where @EntityScan is used to scan all your Entities those are marked @Entity for any configured JPA in your application. @ComponentScan: Configures component scanning directives for use with @Configuration classes. It is as same as writing Spring XML’s <context:component-scan> element. The  value()  attribute may be specified to define specific packages to scan. … Continue reading @ComponentScan vs @EntityScan

@RestController vs @Controller

Both are used to turn any public class into Spring MVC controllers which will be the entry point of any Spring MVC application. Or we can also say that -> @RestController = @Controller + @ResponseBody; Let me explain the above equation in detail. @RestController are used to make PURE REST API Controllers in Spring who’s returned data (JSON or XML) is used by different views … Continue reading @RestController vs @Controller