spring入门(全套资源包括eclip压缩包各种jar包)

spring入门

准备资源

网盘

链接:https://pan.baidu.com/s/1VsG3HQPeERmTB2Zeqt-F4w 
提取码:t8fl
解压后开始使用
C:\Users\Lenovo\Desktop\各种框架安装包\b站spring\尚硅谷框架_雷丰阳_ssm\工具

这个路径下有4个文件,其中有spring专用的eclipse

C:\Users\Lenovo\Desktop\各种框架安装包\b站spring\尚硅谷框架_雷丰阳_ssm\Spring\Spring\lib

这个路径是需要的jar,要注意如果新建java项目而不是web项目,那么将这些包导入l自己建的ib后还需要右键
在这里插入图片描述

下面写第一个程序
理解:对于对象spring没有new一个对象的过程,而是用bean标签向容器注册有一个对象,property标签对对象各个属性赋值

在这里插入图片描述
写这些代码时候很多用到akt+/自动补全
person01.java

package person;

public class person01 {
	private String lastname;
	private int aage;
	private String email;
	public String getLastname() {
		return lastname;
	}
	public void setLastname(String lastname) {
		this.lastname = lastname;
	}
	public int getAage() {
		return aage;
	}
	public void setAage(int aage) {
		this.aage = aage;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	@Override
	public String toString() {
		return "person01 [lastname=" + lastname + ", aage=" + aage + ", email=" + email + "]";
	}

}

testioc.java

package persontest;

import static org.junit.Assert.*;
import org.junit.Assert.*;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import person.person01;

public class testioc {

	@Test
	public void test() {
		//fail("Not yet implemented");
		ApplicationContext ioc=new ClassPathXmlApplicationContext("hellospring01.xml");

		person01 bean = (person01) ioc.getBean("per01");
		System.out.print(bean);
	}

}

uiui.java

package persontest;

import static org.junit.Assert.*;

import org.junit.Test;

public class uiui {

	@Test
	public void test() {
		fail("Not yet implemented");
	}

}

hellospring01.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="per01" class="person.person01"> 
<property name="aage" value="18"></property></bean>

</beans>

运行

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值