zoukankan      html  css  js  c++  java
  • Spring 笔记(二)模块体系

    前言

    在 Spring Boot 出现之前,开发一个 Spring 项目总会需要添加很多依赖。但是我们在配置依赖的时候,往往不太明确各依赖的具体作用,经常是从网上复制粘贴。
    为何需要添加这些依赖?各依赖之间有何关系?某个依赖是否可以省略?要回答这些问题,就有必要了解 Spring 的依赖体系。

    搞清了这些问题后,下次配置依赖时,就能很清楚的知道自己需要添加哪些依赖了。

    Spring Framwork Modules

    这里仅针对 Spring 4 和 Spring 5

    Spring 框架被分解成 20 个左右的模块,这些模块又按功能分成多个类别:
    Overview of the Spring Framework

    Core Container

    核心容器由 spring-core, spring-beans, spring-context, spring-context-support, 和 spring-expression 组成

    spring-core 和 spring-beans

    spring-core 和 spring-beans 是 Spring 的基石,提供了基本的 DI (依赖注入)功能。
    但是我们基本不需要添加这两个依赖,因为我们通常都会使用更上层的模块,而这些上层模块依赖了它们,我们引入上层模块后,依赖管理工具会自动链入下层依赖。

    spring-expression

    spring-expression 定义了强大的 Spring 表达式语言,用于在运行时查询和操作对象。

    spring-context 和 spring-context-support

    spring-context 建立在 core 和 beans 之上,提供了更高层的 API。其核心是 ApplicationContext。
    spring-context-support 则是为将第三方库整合进 Spring 应用上下文 提供支持。

    普通的 Spring 应用只需要引入 spring-context 模块:

    // gradle
    implementation group: 'org.springframework', name: 'spring-context', version: '5.0.7.RELEASE'
    

    从上面的依赖关系图就能知道,四个核心模块都是它的依赖。

    AOP 和 Instrumentation

    这一部分包含下列模块:spring-aop, spring-aspects, spring-instrument, spring-instrument-tomcat

    1. spring-aop 提供了面向切面编程的实现,它允许你定义拦截器 (interceptors) 和 切点 (pointcuts),用以解耦(decouple) 关注点不同的代码。
    2. spring-aspects 整合了 Java 最强大的一个 AOP 库:AspectJ.
    3. spring-instrument 提供了用于某些应用程序服务器的类工具支持和类加载器实现.
    4. spring-instrument-tomcat 是 Spring’s instrumentation agent for Tomcat.

    其他的见参考。。懒啊

    参考

  • 相关阅读:
    Silverlight MMORPG WebGame游戏设计(三)Server和Client的暗号
    Silverlight MMORPG WebGame游戏设计(七)IsolatedStorage,想说爱你不容易
    如何在WP7上用XNA写2D游戏(四)
    Silverlight MMORPG WebGame游戏设计(六)Server和Client的婚后协议[附上完整15M游戏DEMO]
    我的2010年
    如何在WP7上用XNA写2D游戏(一)
    笑话一片
    设计模式简单概括总结2
    设计模式简单概括总结
    ExtJs 4 动态加载grid
  • 原文地址:https://www.cnblogs.com/kirito-c/p/9198297.html
Copyright © 2011-2022 走看看