SpringBoot学习-web(二)

1、main函数上的@SpringBootApplication


SpringBoot学习-web(二)_第1张图片

2、Controller上面的注解——@RestController注解


SpringBoot学习-web(二)_第2张图片

3、方法上面的注解--@RequestMapping


SpringBoot学习-web(二)_第3张图片

4、测试类的注解


SpringBoot学习-web(二)_第4张图片

5、什么时候用@Autowired

[再重温一下,注入到Spring容器中的bean,就类似于new了一个实例对象出来,但是没有被使用]

[用@Component、@Controller、@Service、@Repository注解来定义bean,注入到Spring容器中]

[用@Autowired、@Resource、@Inject来使用bean]

[通过@Autowired自动装配方式,从(实现了IoC设计模式的)Spring容器中去查找到MockMvc,并返回给mockMvc]


SpringBoot学习-web(二)_第5张图片

你可能感兴趣的:(SpringBoot学习-web(二))