
Quick Contact
Java Tutorial
- What is Java?
- History of Java
- Hello Java Program
- Features of Java
- Basic Syntax
- Java Setup
- Data Types in Java
- Java Variables
- Operators in Java
- JVM
- Java If-else Statement
- Switch Case Statement
- Java Loops
- Do-While Loop
- Java While Loop
- Continue Statement
- Break Statement in Java
- Constructors in Java
- Oops Concept in Java
- Features of OOPs
- Inheritance
- Exeception handeling
- Aggregation (HAS-A relationship) in Java
- Method Overriding in Java
- Method Overloading
- Java Static Keyword
- Java This Keyword
- Java Final Keyword
- Polymorphism
- Static Binding and Dynamic Binding
- Abstract class in Java
- Access Modifiers in Java
- Difference between abstract class and interface
- Interface in Java
- Garbage Collection in Java
- Java Package
- Encapsulation
- Serialization and Deserialization in Java
- Java Inner Classes
- Java Applets
- Multithreading in Java
- Thread Priorities in Java
- Thread Creation
- Inter Thread Communication
- Wrapper Classes in Java
- Java Input Output
- Java AWT Introduction
- Java Layout Manager
- Java Layout Policy
- Java AWT Events
- Collection Framework
- Collection Framework List Interface
- Swing in Java
- Swing Utility Classes
- Swing Layout Managers
- Java JDBC
- Hibernate Framework Overview – Architecture and Basics
Springboot
- Spring Environment Setup
- Spring Boot CRUD REST API Project using IntelliJ IDEA | Postman | MySQL
- Dockerizing Spring Boot Application | Spring Boot Docker Tutorial
- spring-boot-restapidocumentation with swagger
- Spring Boot HttpClient Overview
- Apache HttpClient POST HTTP Request Example
- Apache HttpClient PUT HTTP Request Example
- Apache HttpClient DELETE HTTP Request Example
- Apache HttpClient HTML Form POST Request Example
- Spring Boot JSP Exampl
- Deploying Spring Boot WAR file with JSP to Tomcat
- Spring Boot Annotations
- Spring Core Annotations
- Spring MVC Annotations with Examples
- Spring Scheduling Annotations
- Spring - Java-based Container Configuration
- Spring Java Based Configuration Example
Hibernate
- Hibernate 5 hello world
- Hibernate- One to One Unidirectional Mapping Annotation Example
- Hibernate - Batch Processing
- Hibernate - Interceptors
- Hibernate 5 - Create, Read, Update and Delete (CRUD) Operations Example
- Hibernate Transaction Management
- Hibernate One to Many Unidirectional Mapping Example
- Hibernate One to Many Bidirectional Mapping Example
- Hibernate Many to Many Annotation Mapping Example
- Hibernate Primary KeyJoin Column
- Hibernate First Level Cache with Example
- Hibernate XML Configuration Example with Maven + Eclipse + MySQL Database
- Hibernate Java Configuration Example
- JPA 2 with Hibernate 5 Bootstrapping Example
- JPA and Hibernate Cascade Types
- Hibernate/JPA - Primary Key Generation
- Hibernate 5 - Enum Type Mapping Example
- Hibernate Component Mapping
- Hibernate Object States – Transient,Persistent and Detached
- Hibernate 5 - Save an Entity Example
- Hibernate 5 - Persist an Entity Example
- Hibernate 5 - saveOrUpdate() Method Example
- Hibernate 5 - get(), load() and byId() Method Examples
- Hibernate 5 - merge() Example
- Hibernate 5 - Delete or Remove an Entity Example
- Hibernate 5 - load() Method Example
- Hibernate Session Interface Methods
- Hibernate Session.clear() Method Example
- Introduction Of Java strutes to Architecture
- Struts 2 - Architecture
- Struts 2 - Configuration Files
- Struts 2 - Actions
- Struts 2 - Interceptors
- Struts 2 - Results & Result Types
- Struts 2 - Value Stack/OGNL
- Struts 2 - File Uploading
- Struts 2 - Database Access
- Struts 2 - Validations Framework
JAVA FX
- JavaFX Tutorial
- Introduction to JavaFX Pane
- JavaFX Popup
- JavaFX group
- JavaFX Controller
- JavaFX Gradient Color
- JavaFXAnchorPane
- JavaFXTabPane
- JavaFX Scene
- JavaFX Stage
- JavaFXWebView
- JavaFX Timeline
- JavaFX Timer
- JavaFX Image
- JavaFX Background
- JavaFX dialog
- JavaFX Font
- JavaFXTextArea
- JavaFXObservableList
- JavaFX GUI
- JavaFX FXML
- JavaFXEventHandler
- JavaFXGradle
- JavafxScrollpane
- JavaFXAPI
Spring Boot Annotations
Now we’ll explore the annotations from the org.springframework.boot.autoconfigure and org.springframework.boot.autoconfigure.condition packages.
-
Spring Core Annotations
-
Spring Web Annotations
-
Spring Boot Annotations (current article)
(current article)
-
Spring Scheduling Annotations
As we know that Spring Boot is a brand new framework from the team at Pivotal, designed to simplify the bootstrapping and development of a new Spring application. The framework takes an opinionated approach to configuration, freeing developers from the need to define a boilerplate configuration. It provides defaults for code and annotation configuration to quick start new Spring projects within no time.
Spring boot provides many annotations for autoconfiguration from the org.springframework.boot.autoconfigure and org.springframework.boot.autoconfigure.condition packages. Let’s list all the annotations from these packages.
-
@SpringBootApplication
@SpringBootApplication annotation indicates a configuration class that declares one or more @Bean methods and also triggers auto-configuration and component scanning.
The @SpringBootApplication annotation is equivalent to using @Configuration, @EnableAutoConfiguration, and @ComponentScan with their default attributes.
@SpringBootApplication annotation example:
We use this annotation to mark the main class of a Spring Boot application:
importorg.springframework.boot.SpringApplication; importorg.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication // same as @Configuration @EnableAutoConfiguration @ComponentScan public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
Read more about @SpringBootApplication annotation on Spring Boot @SpringBootApplication Annotation with Example.
-
@EnableAutoConfiguration
@EnableAutoConfiguration annotation tells Spring Boot to “guess” how you want to configure Spring, based on the jar dependencies that you have added. Since spring-boot-starter-web dependency added to classpath leads to configure Tomcat and Spring MVC, the auto-configuration assumes that you are developing a web application and sets up Spring accordingly.
@EnableAutoConfiguration annotation example:
Let’s add @EnableAutoConfiguration annotation to Application class or Main class to enable an auto-configuration feature.
importorg.springframework.boot.SpringApplication; importorg.springframework.boot.autoconfigure.EnableAutoConfiguration; @EnableAutoConfiguration public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
Read more about @SpringBootApplication annotation on Spring Boot @EnableAutoConfiguration Annotation with Example
-
@ConditionalOnClass and @ConditionalOnMissingClass
These annotations belong to Class conditions. The @ConditionalOnClass and @ConditionalOnMissingClass annotations let configuration be included based on the presence or absence of specific classes.
Example:
In below example, using these conditions, Spring will only use the marked auto-configuration bean if the class in the annotation’s argument is present/absent:
@Configuration @ConditionalOnClass(DataSource.class) classOracleAutoconfiguration { //... }
-
@ConditionalOnBean and @ConditionalOnMissingBean
The @ConditionalOnBean and @ConditionalOnMissingBean annotations let a bean be included based on the presence or absence of specific beans.
@ConditionalOnBean annotation example:
Use when we want to define conditions based on the presence or absence of a specific bean:
@Bean @ConditionalOnBean(name = "dataSource") LocalContainerEntityManagerFactoryBeanentityManagerFactory() { // ... }
@ConditionalOnMissingBean annotation example:
When placed on a @Bean method, the target type defaults to the return type of the method, as shown in the following example:
@Configuration public class MyAutoConfiguration { @Bean @ConditionalOnMissingBean publicMyServicemyService() { ... } }
In the preceding example, the myService bean is going to be created if no bean of type MyService is already contained in the ApplicationContext.
-
@ConditionalOnProperty
The @ConditionalOnProperty annotation lets configuration be included based on a Spring Environment property.
@ConditionalOnProperty annotation example:
With this annotation, we can make conditions on the values of properties:
@Bean @ConditionalOnProperty( name = "usemysql", havingValue = "local" ) DataSourcedataSource() { // ... }
-
@ConditionalOnResource
The @ConditionalOnResource annotation lets configuration be included only when a specific resource is present:
@ConditionalOnResource(resources = "classpath:mysql.properties") Properties additionalProperties() { // ... }
-
@ConditionalOnWebApplication and @ConditionalOnNotWebApplication
The @ConditionalOnWebApplication and @ConditionalOnNotWebApplication annotations let configuration be included depending on whether the application is a “web application”. A web application is an application that uses a Spring WebApplicationContext, defines a session scope, or has a StandardServletEnvironment.
@ConditionalOnWebApplication annotation sample code:
With these annotations, we can create conditions based on if the current application is or isn’t a web application:
@ConditionalOnWebApplication HealthCheckControllerhealthCheckController() { // ... }
-
@ConditionalExpression
We can use this annotation in more complex situations. Spring will use the marked definition when the SpEL expression is evaluated to true:
@Bean @ConditionalOnExpression("${usemysql} && ${mysqlserver == 'local'}") DataSourcedataSource() { // ... }
-
@Conditional
For even more complex conditions, we can create a class evaluating the custom condition. We tell Spring to use this custom condition with @Conditional:
@Conditional(HibernateCondition.class) Properties additionalProperties() { //... }
Apply now for Advanced Java Training Course