Spring简介,简单认识一下Spring

Sping简介

1 简介

  • spring:春天————>给开发程序员行业带来了春天
  • 2002,首次推出了spring框架的雏形:基于interface21框架
  • spring框架于2004年3月24日,发布1.0正式版
  • spring的理论:使现有的技术更加容易使用
  • 本身是一个打杂烩,整合了现有的技术框架

gitHub:https://github.com/spring-projects/spring-framework

spring官网:https://spring.io/projects/spring-framework#learn

spring jar包 :

<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>5.2.2.RELEASE</version>
</dependency>

spring 配置元数据

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        https://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="..." class="...">  
        <!-- collaborators and configuration for this bean go here -->
    </bean>

    <bean id="..." class="...">
        <!-- collaborators and configuration for this bean go here -->
    </bean>

    <!-- more bean definitions go here -->

</beans>

**注意:Spring IoC容器使用一种形式的配置元数据。此配置元数据表示您作为应用程序开发人员如何告诉Spring容器实例化,配置和组装应用程序中的对象。

传统上,配置元数据以简单直观的XML格式提供,这是本章大部分内容用来传达Spring IoC容器的关键概念和功能的内容。**
有关在Spring容器中使用其他形式的元数据的信息,请参见:

基于注释的配置:Spring 2.5引入了对基于注释的配置元数据的支持。

基于Java的配置:从Spring 3.0开始,Spring JavaConfig项目提供的许多功能成为核心Spring Framework的一部分。因此,您可以使用Java而不是XML文件来定义应用程序类外部的bean。要使用这些新功能,请参阅 @Configuration, @Bean, @Import,和@DependsOn注释。

1.2.2。实例化容器

提供给ApplicationContext构造函数的位置路径是资源字符串,这些资源字符串使容器可以从各种外部资源(例如本地文件系统,Java等)加载配置元数据CLASSPATH。#

ApplicationContext context = new ClassPathXmlApplicationContext("services.xml", "daos.xml");

2 spring的优点

  • spring是一个开源的免费的框架(容器)
  • spring是一个轻量级的、非入侵式的框架
  • 控制反转(IOC),面向切面编程(aop)
  • 支持事务的处理,对框架整个的支持

3 说说扩展

spring发展历史如此之长,更新版本也频繁,后面延伸了springBoot,spring Cloud

  • spring Boot

    • 它是一个快速开发的脚手架,也就是说越高层的框架,编程就变得越简单。
    • SpringBoot可以快速开发单个微服务。
    • 约定大于配置(这跟maven是一样的)
  • Spring Cloud

    • Spring Cloud是基于SpringBoot实现的。

总的来说,现在流行使用SpringBoot进行快速开发,学习SpringBoot的前提,需要完全掌握Spring、SpringMvc ,只要掌握了这两个的基本原理和配置,后面学的都会轻松。

posted @ 2020-04-06 18:48  三毛是学IT掉发的  阅读(688)  评论(0编辑  收藏  举报