从小白的角度看Spring核心流程概览(XML版)-准备篇

#自我介绍 小白一枚,距离上一篇文章好像过去很久很久了(无视这个吧~)。最近闲来无事,就想着看看Spring的源码,和大家一起学习。如果有不对的对方请大家提出来(你T喵的来打我啊o( ̄︶ ̄)o)~

#一、准备工作 本次的演示版本是最新的Spring5.1.0.RELEASE。开发工具使用idea2017.01版本。 #二、环境搭建 ##2.1、POM文件

<dependencies>
	<dependency>
	<groupId>org.springframework</groupId>
	<artifactId>spring-context</artifactId>
	<version>5.1.0.RELEASE</version>
	</dependency>
</dependencies>

##2.2、一个简答的实体类

public class User {

    private Long id;

    private String name;

    private Integer age;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}

##2.3、一份xml文件

<?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="user" class="com.ricky.domain.User">
        <property name="id" value="1"></property>
        <property name="age" value="24"></property>
        <property name="name" value="Ricky"></property>
    </bean>

</beans>

##2.4、一个启动类测试类

package com.ricky;


import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MySpringDemo {

    public static void main(String[] args) {
        ClassPathXmlApplicationContext context =
                new ClassPathXmlApplicationContext("ApplicationContext.xml");
        System.out.println(context.getBean("user"));
    }

}

##2.5整体目录结构

好了,话不多说。Begin Game!

转载于:https://my.oschina.net/u/3367603/blog/2207013

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值