Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
檀越@新空间
spring-study
提交
02ab1cf9
S
spring-study
项目概览
檀越@新空间
/
spring-study
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-study
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
02ab1cf9
编写于
11月 12, 2022
作者:
Q
qinyingjie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:测试添加编号
上级
2a2f9db1
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
157 addition
and
10 deletion
+157
-10
src/main/java/com/kwan/spring5/Dept.java
src/main/java/com/kwan/spring5/Dept.java
+26
-0
src/main/java/com/kwan/spring5/Emp.java
src/main/java/com/kwan/spring5/Emp.java
+44
-0
src/main/resources/spring5.xml
src/main/resources/spring5.xml
+24
-0
src/test/java/Spring_01_XmlGetTest.java
src/test/java/Spring_01_XmlGetTest.java
+2
-5
src/test/java/Spring_02_UserTest.java
src/test/java/Spring_02_UserTest.java
+33
-0
src/test/java/Spring_03_OrdersTest.java
src/test/java/Spring_03_OrdersTest.java
+1
-1
src/test/java/Spring_04_BookTest_01.java
src/test/java/Spring_04_BookTest_01.java
+1
-1
src/test/java/Spring_04_BookTest_02.java
src/test/java/Spring_04_BookTest_02.java
+1
-1
src/test/java/Spring_04_BookTest_03.java
src/test/java/Spring_04_BookTest_03.java
+1
-1
src/test/java/Spring_05_UserServiceTest.java
src/test/java/Spring_05_UserServiceTest.java
+1
-1
src/test/java/Spring_06_DeptTest.java
src/test/java/Spring_06_DeptTest.java
+23
-0
未找到文件。
src/main/java/com/kwan/spring5/Dept.java
0 → 100644
浏览文件 @
02ab1cf9
package
com.kwan.spring5
;
/**
* 部门
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2022/11/12 20:00
*/
public
class
Dept
{
/**
* 名称
*/
private
String
dname
;
public
void
setDname
(
String
dname
)
{
this
.
dname
=
dname
;
}
@Override
public
String
toString
()
{
return
"Dept{"
+
"dname='"
+
dname
+
'\''
+
'}'
;
}
}
src/main/java/com/kwan/spring5/Emp.java
0 → 100644
浏览文件 @
02ab1cf9
package
com.kwan.spring5
;
/**
* 员工
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2022/11/12 20:01
*/
public
class
Emp
{
/**
* 姓名
*/
private
String
ename
;
/**
* 性别
*/
private
String
gender
;
/**
* 员工属于某一个部门,使用对象形式表示
*/
private
Dept
dept
;
public
void
setDept
(
Dept
dept
)
{
this
.
dept
=
dept
;
}
public
void
setEname
(
String
ename
)
{
this
.
ename
=
ename
;
}
public
void
setGender
(
String
gender
)
{
this
.
gender
=
gender
;
}
@Override
public
String
toString
()
{
return
"Emp{"
+
"ename='"
+
ename
+
'\''
+
", gender='"
+
gender
+
'\''
+
", dept="
+
dept
+
'}'
;
}
}
src/main/resources/spring5.xml
0 → 100644
浏览文件 @
02ab1cf9
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:context=
"http://www.springframework.org/schema/context"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd"
>
<context:annotation-config/>
<!--内部bean-->
<bean
id=
"emp"
class=
"com.kwan.spring5.Emp"
>
<!--设置两个普通属性-->
<property
name=
"ename"
value=
"Andy"
></property>
<property
name=
"gender"
value=
"女"
></property>
<!--设置对象类型属性-->
<property
name=
"dept"
>
<bean
class=
"com.kwan.spring5.Dept"
>
<!--内部bean赋值-->
<property
name=
"dname"
value=
"宣传部门"
></property>
</bean>
</property>
</bean>
</beans>
\ No newline at end of file
src/test/java/
User
Test.java
→
src/test/java/
Spring_01_XmlGet
Test.java
浏览文件 @
02ab1cf9
...
...
@@ -10,7 +10,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
* @version : 2.2.0
* @date : 2022/11/12 18:43
*/
public
class
User
Test
{
public
class
Spring_01_XmlGet
Test
{
@Test
public
void
test1
()
{
...
...
@@ -30,7 +30,4 @@ public class UserTest {
User
user
=
(
User
)
ctx
.
getBean
(
"user"
);
user
.
say
();
}
}
//1.修改快捷键爱你
//2.修改测试类名
\ No newline at end of file
}
\ No newline at end of file
src/test/java/Spring_02_UserTest.java
0 → 100644
浏览文件 @
02ab1cf9
import
com.kwan.spring5.User
;
import
org.junit.Test
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.support.ClassPathXmlApplicationContext
;
/**
* 测试ioc注入
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2022/11/12 18:43
*/
public
class
Spring_02_UserTest
{
@Test
public
void
test1
()
{
System
.
out
.
println
(
"test1"
);
ClassPathXmlApplicationContext
ctx
=
new
ClassPathXmlApplicationContext
(
"spring1.xml"
);
User
user
=
(
User
)
ctx
.
getBean
(
"user"
);
user
.
say
();
}
@Test
public
void
test2
()
{
System
.
out
.
println
(
"test2"
);
ApplicationContext
ctx
=
new
ClassPathXmlApplicationContext
(
"spring1.xml"
);
User
user
=
(
User
)
ctx
.
getBean
(
"user"
);
user
.
say
();
}
}
\ No newline at end of file
src/test/java/OrdersTest.java
→
src/test/java/
Spring_03_
OrdersTest.java
浏览文件 @
02ab1cf9
...
...
@@ -11,7 +11,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
* @version : 2.2.0
* @date : 2022/11/12 18:43
*/
public
class
OrdersTest
{
public
class
Spring_03_
OrdersTest
{
@Test
public
void
test1
()
{
...
...
src/test/java/BookTest_01.java
→
src/test/java/
Spring_04_
BookTest_01.java
浏览文件 @
02ab1cf9
...
...
@@ -11,7 +11,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
* @version : 2.2.0
* @date : 2022/11/12 18:43
*/
public
class
BookTest_01
{
public
class
Spring_04_
BookTest_01
{
@Test
public
void
test1
()
{
...
...
src/test/java/BookTest_02.java
→
src/test/java/
Spring_04_
BookTest_02.java
浏览文件 @
02ab1cf9
...
...
@@ -11,7 +11,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
* @version : 2.2.0
* @date : 2022/11/12 18:43
*/
public
class
BookTest_02
{
public
class
Spring_04_
BookTest_02
{
@Test
public
void
test1
()
{
...
...
src/test/java/BookTest_03.java
→
src/test/java/
Spring_04_
BookTest_03.java
浏览文件 @
02ab1cf9
...
...
@@ -10,7 +10,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
* @version : 2.2.0
* @date : 2022/11/12 18:43
*/
public
class
BookTest_03
{
public
class
Spring_04_
BookTest_03
{
@Test
public
void
test1
()
{
...
...
src/test/java/UserServiceTest.java
→
src/test/java/
Spring_05_
UserServiceTest.java
浏览文件 @
02ab1cf9
...
...
@@ -11,7 +11,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
* @version : 2.2.0
* @date : 2022/11/12 18:43
*/
public
class
UserServiceTest
{
public
class
Spring_05_
UserServiceTest
{
@Test
public
void
test2
()
{
...
...
src/test/java/Spring_06_DeptTest.java
0 → 100644
浏览文件 @
02ab1cf9
import
com.kwan.spring5.Emp
;
import
com.kwan.spring5.User
;
import
org.junit.Test
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.support.ClassPathXmlApplicationContext
;
/**
* 测试ioc注入
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2022/11/12 18:43
*/
public
class
Spring_06_DeptTest
{
@Test
public
void
test1
()
{
ApplicationContext
ctx
=
new
ClassPathXmlApplicationContext
(
"spring5.xml"
);
Emp
emp
=
(
Emp
)
ctx
.
getBean
(
"emp"
);
System
.
out
.
println
(
emp
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录