Understanding the need for a DI framework

前端 未结 12 1766
长情又很酷
长情又很酷 2020-12-07 12:39

This might be a naive question. I\'m currently learning the Spring framework and dependency injection. While the basic principle of DI is rather easy to grasp, it\'s

12条回答
  •  醉梦人生
    2020-12-07 13:36

    It's important to understand that Spring is fundamentally two things, one built on top of the other:

    1. A lightweight DI/IoC framework and the classes to implement that (eg XML application contexts, etc); and
    2. It is a lightweight container.

    (2) is the bulk of the Spring code. Basically pick a Java technology and you'll probably find Spring has helper classes for it. This is so you can use ActiveMQ, Sun One MQ or whatever and abstract them being a Spring JmsTemplate and the same goes for data access technologies, Web services, etc.

    All of these helpers use (1) to wire them together.

提交回复
热议问题