Skip to content

Commit 3958ee6

Browse files
committed
upload
1 parent b605aed commit 3958ee6

File tree

31 files changed

+2704
-0
lines changed

31 files changed

+2704
-0
lines changed

javaframework/spring/第一节课/code/spring_study/.idea/misc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

javaframework/spring/第一节课/code/spring_study/.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

javaframework/spring/第一节课/code/spring_study/.idea/workspace.xml

Lines changed: 425 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
5+
6+
<!--bean标签表示要创建的bean对象
7+
id:bean的唯一标识,为了跟其他的bean区分
8+
class:表示要创建的bean的完全限定名
9+
-->
10+
<bean id="person" class="com.mashibing.bean.Person">
11+
<!--给属性赋值使用property标签
12+
name:表示属性的名称
13+
value:表示具体的属性值
14+
-->
15+
<property name="id" value="1"></property>
16+
<property name="name" value="zhangsan"></property>
17+
<property name="age" value="20"></property>
18+
<property name="gender" value=""></property>
19+
</bean>
20+
</beans>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
<orderEntry type="library" name="spring-beans-5.2.3.RELEASE" level="application" />
11+
<orderEntry type="library" name="commons-logging-1.2" level="application" />
12+
</component>
13+
</module>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.mashibing.bean;
2+
3+
public class Person {
4+
private int id;
5+
private String name;
6+
private int age;
7+
private String gender;
8+
9+
public Person() {
10+
System.out.println("person被创建");
11+
}
12+
13+
public int getId() {
14+
return id;
15+
}
16+
17+
public void setId(int id) {
18+
this.id = id;
19+
}
20+
21+
public String getName() {
22+
return name;
23+
}
24+
25+
public void setName(String name) {
26+
this.name = name;
27+
}
28+
29+
public int getAge() {
30+
return age;
31+
}
32+
33+
public void setAge(int age) {
34+
this.age = age;
35+
}
36+
37+
public String getGender() {
38+
return gender;
39+
}
40+
41+
public void setGender(String gender) {
42+
this.gender = gender;
43+
}
44+
45+
@Override
46+
public String toString() {
47+
return "Person{" +
48+
"id=" + id +
49+
", name='" + name + '\'' +
50+
", age=" + age +
51+
", gender='" + gender + '\'' +
52+
'}';
53+
}
54+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.mashibing.test;
2+
3+
import com.mashibing.bean.Person;
4+
import org.springframework.context.ApplicationContext;
5+
import org.springframework.context.support.ClassPathXmlApplicationContext;
6+
7+
//容器中的person对象是什么时候创建的?
8+
//容器中的对象在容器创建完成之前就已经把对象创建好了
9+
public class MyTest {
10+
public static void main(String[] args) {
11+
/*
12+
* applicationContext:表示IOC容器的入口,想要获取对象的话,必须要创建该类
13+
* 该类有两个读取配置文件的实现类
14+
* ClassPathXmlApplicationContext:表示从classpath中读取数据
15+
* FileSystemXmlApplicationContext:表示从当前文件系统读取数据
16+
*
17+
*
18+
* * */
19+
ApplicationContext context = new ClassPathXmlApplicationContext("ioc.xml");
20+
//获取具体的bean实例对象,需要进行强制类型转换
21+
// Person person = (Person) context.getBean("person");
22+
//获取对象的时候不需要强制类型转换
23+
// Person person = context.getBean("person", Person.class);
24+
// System.out.println(person);
25+
}
26+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
5+
6+
<!--bean标签表示要创建的bean对象
7+
id:bean的唯一标识,为了跟其他的bean区分
8+
class:表示要创建的bean的完全限定名
9+
-->
10+
<bean id="person" class="com.mashibing.bean.Person">
11+
<!--给属性赋值使用property标签
12+
name:表示属性的名称
13+
value:表示具体的属性值
14+
-->
15+
<property name="id" value="1"></property>
16+
<property name="name" value="zhangsan"></property>
17+
<property name="age" value="20"></property>
18+
<property name="gender" value=""></property>
19+
</bean>
20+
</beans>

0 commit comments

Comments
 (0)