
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 Java Based Configuration Example
We use @Configuration and @Bean annotations to develop spring application. Note that we haven’t used @Service or @Component annotation in this example. (annotation based configuration)
In this article, we will use @Configuration, @Bean and @Import annotations to demonstrate Spring Java-based configuration example.
Let’s create AppConfiguration and AppConfiguration2 Java classes and annotated with @Configuration annotation. In Java-based configuration auto component scanning not required because Spring beans are created by using factory methods annotated with @Bean annotation.
@Import – much as the element is used within Spring XML files to aid in modularizing configurations, the @Import annotation allows for loading @Bean definitions from another configuration class.
We have created two configuration files and now we will use @Import annotation to import an AppConfiguration2 file into a main AppConfiguration config file.
@Configuration public class AppConfiguration2 { @Bean(name="twitterService") publicMessageServicetwitterService(){ return new TwitterService(); } @Bean publicMessageProcessormessageProcessor(){ return new MessageProcessorImpl(twitterService()); } }
Let’s create main app Java-based configuration class.
@Configuration @ComponentScan("com.ducatindia.springframework.di") @Import(AppConfiguration2.class) publicclassAppConfiguration { @Bean(name="emailService") publicMessageServiceemailService(){ returnnewEmailService(); } @Bean(name="smsService") publicMessageServicesmsService(){ returnnewSMSService(); } }
Create MessageService interface and it’s multiple implementations.
public interface MessageService { public void sendMsg(String message); } publicclassSMSServiceimplementsMessageService{ publicvoidsendMsg(Stringmessage) { System.out.println(message); } } publicclassEmailServiceimplementsMessageService{ publicvoidsendMsg(Stringmessage) { System.out.println(message); } } publicclassTwitterServiceimplementsMessageService{ publicvoidsendMsg(Stringmessage) { System.out.println(message); } } publicinterfaceMessageProcessor { publicvoidprocessMsg(Stringmessage); } public class MessageProcessorImpl implements MessageProcessor { privateMessageServicemessageService; @Autowired publicMessageProcessorImpl(@Qualifier("TwitterService") MessageServicemessageService) { this.messageService = messageService; } public void processMsg(String message) { messageService.sendMsg(message); } }
Let’s test this application:
public class TestApplication { public static void main(String[] args) { ApplicationContextapplicationContext = new AnnotationConfigApplicationContext(AppConfiguration.class); MessageProcessoruserService = applicationContext.getBean(MessageProcessor.class); userService.processMsg("Student message sending "); } }
Output:
Student message sending
In this example, we used some of the annotations like @Configuration, @Bean, and @Import annotations to demonstrate Spring Java-based configuration. The implementation of this simple Spring Java-based-configuration example can be found in the GitHub project – this is an Eclipse based project, so it should be easy to import and run as it is.
Apply now for Advanced Java Training Course