| Start |
|---|
| Setup (XML Configuration) Steps to create Hello Spring:
|
Showcasing Core Spring Features by example DescriptionThis is a self-contained running example including/showcasing: minimum dependencies needed, Java Configuration, Bean declaration by annotation and Java Configuration, Dependency Injection by Constructor and by Property, and Pre/Post hooks. DependenciesThese dependencies are needed in the classpath:
Main ClassStarting from the end, this is our Main class that serves as a placeholder for the Application Configuration fileThe configuration class is annotated by Bean Declaration by AnnotationThe Bean Declaration by Application ConfigurationNotice that we don't need to annotate or otherwise mark our POJO since the bean declaration/definition is happening in the Application Configuration class file. Constructor InjectionNotice that the Property InjectionNotice that the PostConstruct / PreDestroy hooksWe can intercept initialisation and destruction of a Bean by the |
| What is Spring Framework, why should we go for it ? Spring is a framework, which provides bunch of classes, by using this we don't need to write boiler plate logic in our code, so Spring provides an abstract layer on J2ee. For Example in Simple JDBC Application programmer is responsible for
Which is treated as boilerplate code as every programmer write the same code. So for simplicity the framework takes care of boilerplate logic and the programmer has to write only business logic. So by using Spring framework we can develop projects rapidly with minimum lines of code, without any bug, the development cost and time also reduced. So Why to choose Spring as struts is thereStrut is a framework which provide solution to web aspects only and struts is invasive in nature. Spring has many features over struts so we have to choose Spring.
So finally we can say Spring is an alternative to Struts. But Spring is not a replacement of J2EE API, As Spring supplied classes internally uses J2EE API classes. Spring is a vast framework so it has divided into several modules. No module is dependent to another except Spring Core. Some Important modules are
RemarksThe Spring Framework is an open source application framework and inversion of control container for the Java platform. |
Read Article
https://develop.horje.com/learn/1434/reference