简体   繁体   中英

Java Spring Injection

I have just started using and educating my self of Java spring. I now know that we can inject beans.

But on the look of it it looks like a glorified properties file, am i right in thinking that way ?

No, absolutely not. This couldn't be more wrong.

Spring is about three things:

  1. dependency injection (think "factory pattern")
  2. aspect oriented programming
  3. a framework that handles persistence, remoting, transactions, messaging, etc. better than any plumbing you'll ever write.

If you only see "glorified properties", you've got a very long way to go in your Spring education. Keep reading.

Dependency Injection is just one part of the Spring Framework, which is extremely good at making sure that you structure your code in an efficient way for testing and substituting in different implementations of interfaces.

There are also the various Spring API's which make working with aspects, Databases, JMS, Transactions etc. much easier and allow you to produce robust applications without worrying about all the plumbing code. The template pattern for transactions and JMS make creating J2EE applications much easier.

The Spring Web framework is also excellent for building MVC web applications.

Spring Integration and Batch projects are also extremely useful.

The core concepts of spring would be dependency injection(DI) and Aspect oriented programming (AOP). Apart from that, spring framework makes developer life much simpler in:

  1. Building MVC application.
  2. Integrating with ORM like Hibernate,JPA
  3. Handling transaction.
  4. Integrating security like Oauth2
  5. Integrating cache to your application
  6. Scheduling jobs etc.

For more information, check this out: https://spring.io/projects

If you are just starting, them I would suggest you to try Spring Boot, where configuring project is much simplified.

I hope, it helped.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM