Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
unravel space
后端学习测试
提交
31e89f54
后
后端学习测试
项目概览
unravel space
/
后端学习测试
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
后
后端学习测试
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
31e89f54
编写于
4月 09, 2024
作者:
unravel space
😆
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
注解spring开发测试
上级
c6e1b373
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
157 addition
and
0 deletion
+157
-0
spring-framework-test/spring-annocation/pom.xml
spring-framework-test/spring-annocation/pom.xml
+19
-0
spring-framework-test/spring-annocation/src/main/java/com/test/annocation/config/SpringConfig.java
...rc/main/java/com/test/annocation/config/SpringConfig.java
+20
-0
spring-framework-test/spring-annocation/src/main/java/com/test/annocation/dao/BookDao.java
...cation/src/main/java/com/test/annocation/dao/BookDao.java
+16
-0
spring-framework-test/spring-annocation/src/main/java/com/test/annocation/dao/impl/BookDaoImpl.java
...c/main/java/com/test/annocation/dao/impl/BookDaoImpl.java
+25
-0
spring-framework-test/spring-annocation/src/main/java/com/test/annocation/service/BookService.java
...rc/main/java/com/test/annocation/service/BookService.java
+16
-0
spring-framework-test/spring-annocation/src/main/java/com/test/annocation/service/impl/BookServiceImpl.java
...ava/com/test/annocation/service/impl/BookServiceImpl.java
+24
-0
spring-framework-test/spring-annocation/src/test/java/com/test/annocation/controller/AnnocationController.java
.../com/test/annocation/controller/AnnocationController.java
+37
-0
未找到文件。
spring-framework-test/spring-annocation/pom.xml
0 → 100644
浏览文件 @
31e89f54
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
spring-framework-test
</artifactId>
<groupId>
com.test
</groupId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
spring-annocation
</artifactId>
<properties>
<maven.compiler.source>
17
</maven.compiler.source>
<maven.compiler.target>
17
</maven.compiler.target>
</properties>
</project>
\ No newline at end of file
spring-framework-test/spring-annocation/src/main/java/com/test/annocation/config/SpringConfig.java
0 → 100644
浏览文件 @
31e89f54
package
com.test.annocation.config
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Configuration
;
/**
*
*<p>des</p>
*
* @project spring-framework-test
* @description
* @author Phoenix
* @Date 2024/4/9 10:43:17
* @version 1.0
**/
@Configuration
@ComponentScan
({
"com.test.annocation"
})
public
class
SpringConfig
{
}
spring-framework-test/spring-annocation/src/main/java/com/test/annocation/dao/BookDao.java
0 → 100644
浏览文件 @
31e89f54
package
com.test.annocation.dao
;
/**
*
*<p>des</p>
*
* @project spring-framework-test
* @description
* @author Phoenix
* @Date 2024/4/9 10:45:11
* @version 1.0
**/
public
interface
BookDao
{
public
void
save
();
}
spring-framework-test/spring-annocation/src/main/java/com/test/annocation/dao/impl/BookDaoImpl.java
0 → 100644
浏览文件 @
31e89f54
package
com.test.annocation.dao.impl
;
import
com.test.annocation.dao.BookDao
;
import
org.springframework.stereotype.Component
;
/**
*
*<p>des</p>
*
* @project spring-framework-test
* @description
* @author Phoenix
* @Date 2024/4/9 10:45:49
* @version 1.0
**/
@Component
(
"bookDao"
)
public
class
BookDaoImpl
implements
BookDao
{
@Override
public
void
save
()
{
System
.
out
.
println
(
"dao save ..."
);
}
}
spring-framework-test/spring-annocation/src/main/java/com/test/annocation/service/BookService.java
0 → 100644
浏览文件 @
31e89f54
package
com.test.annocation.service
;
/**
*
*<p>des</p>
*
* @project spring-framework-test
* @description
* @author Phoenix
* @Date 2024/4/9 10:45:27
* @version 1.0
**/
public
interface
BookService
{
public
void
save
();
}
spring-framework-test/spring-annocation/src/main/java/com/test/annocation/service/impl/BookServiceImpl.java
0 → 100644
浏览文件 @
31e89f54
package
com.test.annocation.service.impl
;
import
com.test.annocation.service.BookService
;
import
org.springframework.stereotype.Component
;
/**
*
*<p>des</p>
*
* @project spring-framework-test
* @description
* @author Phoenix
* @Date 2024/4/9 10:46:07
* @version 1.0
**/
@Component
(
"bookService"
)
public
class
BookServiceImpl
implements
BookService
{
@Override
public
void
save
()
{
System
.
out
.
println
(
"bookService save ..."
);
}
}
spring-framework-test/spring-annocation/src/test/java/com/test/annocation/controller/AnnocationController.java
0 → 100644
浏览文件 @
31e89f54
package
com.test.annocation.controller
;
import
com.test.annocation.config.SpringConfig
;
import
com.test.annocation.dao.BookDao
;
import
com.test.annocation.service.BookService
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
/**
*
*<p>des</p>
*
* @project spring-framework-test
* @description
* @author Phoenix
* @Date 2024/4/9 12:19:54
* @version 1.0
**/
public
class
AnnocationController
{
@Test
public
void
test01
(){
AnnotationConfigApplicationContext
ctx
=
new
AnnotationConfigApplicationContext
(
SpringConfig
.
class
);
BookService
bookService
=
ctx
.
getBean
(
"bookService"
,
BookService
.
class
);
bookService
.
save
();
BookDao
bookDao
=
ctx
.
getBean
(
"bookDao"
,
BookDao
.
class
);
bookDao
.
save
();
}
@Test
public
void
test02
(){
AnnotationConfigApplicationContext
ctx
=
new
AnnotationConfigApplicationContext
(
SpringConfig
.
class
);
BookService
bookService
=
ctx
.
getBean
(
"bookService"
,
BookService
.
class
);
bookService
.
save
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录