摘要:
1 导入Spring集成Junit的坐标 2 使用@RunWith注解替换原来的运行期 3 使用@ContextConfiguration指定配置文件或配置类 4 使用@Autowired注入需要测试的对象 5 创建测试方法进行测试 package test; import java.sql.SQL 阅读全文
posted @ 2022-11-24 17:49
Cuora
阅读(34)
评论(0)
推荐(0)
摘要:
@Configuration 用于指定当前类是一个Spring配置类,创建容器时会在该类上加载注解 @ComponentScan 用于指定Spring在初始化容器时要扫描的包 @Bean 在方法上使用,标注将该方法的返回值存储到Spring容器中 @PropertySource 用于加载proper 阅读全文
posted @ 2022-11-24 11:25
Cuora
阅读(19)
评论(0)
推荐(0)
摘要:
@Component 在类上用于实例化Bean @Controller 在web层的类上用于实例化Bean @Service 在service层的类上用于实例化Bean @Repository 在dao层的类上用于实例化Bean @Autowired 在字段上用于根据类型依赖注入 @Qualifie 阅读全文
posted @ 2022-11-24 11:14
Cuora
阅读(21)
评论(0)
推荐(0)