Spring 常用配置:Bean的Scope

Spring 常用配置:Bean的Scope_第1张图片
项目结构图


Spring 常用配置:Bean的Scope_第2张图片
pom.xml


Spring 常用配置:Bean的Scope_第3张图片
DemoSingletonService.class


Spring 常用配置:Bean的Scope_第4张图片
DemoProtoTypeService.class


Spring 常用配置:Bean的Scope_第5张图片
ScopeConfig.class


Spring 常用配置:Bean的Scope_第6张图片
Main.class

这个工程有一点小插曲,idea刚开始学使用,创建新java类没有包名,后来在Main下面新建了一个package,写上了包名,然后ScopeConfig中的@ComponentScan 才得以实现扫描整个包。

你可能感兴趣的:(Spring 常用配置:Bean的Scope)