zoukankan      html  css  js  c++  java
  • 课时1:Spring环境搭建、STS工具、第一个Spring程序

    .1)概要以及介绍

      1.2002 作者 Rod Jonnon 发布了一篇文章<Expoer One-toOne j2eedvelopment and Design>

      2.2003年根据这篇文章产生了一些感悟 产生了Spring

      3.spring最基础的核心AOP IOC

      4.经过了18年的的洗礼衍生出很多框架 Spring Data,Spring Boot ,Spring Cloud,Spring Framework,Springsocial

    .2)IOC:控制反转 (DI:依赖注入)

      1.搭建Spring的环境

        1.1 导入spring的依赖jar包

      <!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-context</artifactId>
          <version>4.3.9.RELEASE</version>
        </dependency>
         <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
        <dependency>
          <groupId>org.projectlombok</groupId>
          <artifactId>lombok</artifactId>
          <version>1.18.10</version>
          <scope>provided</scope>
        </dependency>

        1.2 编写配置文件

    <?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 http://www.springframework.org/schema/beans/spring-beans.xsd">
    
    </beans>

      2.开发Spring程序(IOC)

        2.1 编写配置文件

    <?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 http://www.springframework.org/schema/beans/spring-beans.xsd">
    <bean id="student" class="net.bdqn.hbz.pojo.Student">
        <property name="stuno" value="1"></property>
        <property name="stuName" value="zs"></property>
        <property name="stuAge" value="24"></property>
    </bean>
    </beans>

          2.1.1 id:唯一标识符 class:指定类的路径

          2.1.2 property标签 :代表该class的属性

            2.1.2.1 name:属性名称

            2.1.2.1 value :属性值

        2.2 通过bean的id来获取一个对象

    //创建上下文对象
            ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
            //通过bean的id来获取对象
            Student student =(Student) context.getBean("student");
            System.out.println(student);

      3.这样写的一些分析以及好处

        3.1 不需要new

        3.2 对象属性的赋值

        3.3 在applicationContext.xml中产生的对象,被spring放入了一个 称为Spring IOC容器里面

  • 相关阅读:
    Client API Object Model
    Dynamics 365 CRM 配置field service mobile
    Dynamics 365 CRM 在 Connected Field Service 中部署 IoT Central (三)- 发送 work order 和 booking 信息给 IoT Central
    Dynamics 365 CRM 在 Connected Field Service 中部署 IoT Central (二)- 匹配设备
    Dynamics 365 CRM 在 Connected Field Service 中部署 IoT Central (一)- 配置 IoT Central和IoT alert
    创建dynamics CRM client-side (十四)
    创建dynamics CRM client-side (十三)
    创建dynamics CRM client-side (十二)
    创建dynamics CRM client-side (十一)
    创建dynamics CRM client-side (十)
  • 原文地址:https://www.cnblogs.com/thisHBZ/p/12484316.html
Copyright © 2011-2022 走看看