spring源码加载与测试

17 篇文章 0 订阅
spring-framework源码加载与测试
源码

github/spring-framework

Gradle(类似maven,ant)Build Tool

Gradle官网

install Gradle

在这里插入图片描述

open spring-framework

IDEA

编译

在这里插入图片描述

依次找到spring-core,spring-oxm,spring-context,spring-beans,spring-aspects,spring-aop对应如图compileTestJava,并双击执行完成编译,可能中间会存在一些编码之类的warning可以先pass

add module

在这里插入图片描述

  • 选择Gradle-Java,next,finish
    在这里插入图片描述
修改build.gradle

在这里插入图片描述

添加POJO、XML
  • POJO
public class Doimyakon {

	private String username;
	private String password;

}
  • XML
<?xml version="1.0" encoding="UTF-8"?>

<!--根标签beans,里面配置一个又一个的bean子标签,每一个bean子标签都代表一个类的配置-->
<beans xsi:schemaLocation=" http://www.springframework.org/schema/beans
	https://www.springframework.org/schema/beans/spring-beans.xsd
	http://www.springframework.org/schema/tx
	https://www.springframework.org/schema/tx/spring-tx.xsd "
	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	   xmlns:tx="http://www.springframework.org/schema/tx"
	   xmlns="http://www.springframework.org/schema/beans">
	<bean id="doimyakon" class="Doimyakon"></bean>
</beans>
  • Test
public class IocTest {
	@Test
	public void testIoc(){
		ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
		Doimyakon doimyakon = applicationContext.getBean(Doimyakon.class);
		System.out.println(doimyakon);
	}

}
  • 运行
    在这里插入图片描述
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值