博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
@SpringBootApplication
阅读量:5998 次
发布时间:2019-06-20

本文共 1386 字,大约阅读时间需要 4 分钟。

@SpringBootApplication is a convenience annotation that adds all of the following:@Configuration tags the class as a source of bean definitions for the application context.@EnableAutoConfiguration tells Spring Boot to start adding beans based on classpath settings, other beans, and various property settings.Normally you would add @EnableWebMvc for a Spring MVC app, but Spring Boot adds it automatically when it sees spring-webmvc on the classpath.  This flags the application as a web application and activates key behaviors such as setting up a DispatcherServlet.@ComponentScan tells Spring to look for other components, configurations, and services in the hello package, allowing it to find the controllers.
The MockMvc comes from Spring Test and allows you, via a set of convenient builder classes, to send HTTP requests into the DispatcherServlet and make assertions about the result. Note the use of the @AutoConfigureMockMvc together with @SpringBootTest to inject a MockMvc instance. Having used @SpringBootTest we are asking for the whole application context to be created. An alternative would be to ask Spring Boot to create only the web layers of the context using the @WebMvcTest. Spring Boot automatically tries to locate the main application class of your application in either case, but you can override it, or narrow it down, if you want to build something different.

 

转载地址:http://zuzmx.baihongyu.com/

你可能感兴趣的文章
js设计模式--迭代器模式
查看>>
Python 学习笔记之——用 sklearn 对数据进行预处理
查看>>
阿里云ECS连接数据库教程方法
查看>>
react
查看>>
PostgreSQL 10.1 手册_部分 IV. 客户端接口_第 33 章 libpq - C 库_33.21. 例子程序
查看>>
iOS 性能优化
查看>>
Spread for Windows Forms高级主题(7)---自定义打印的外观
查看>>
【循序渐进学Python】5.Python常用流程控制及其他语句
查看>>
[LeetCode] Intersection of Two Arrays II 两个数组相交之二
查看>>
winpcap 发送数据包
查看>>
在centos系统shell脚本中cat和重定向符号<<EOF结合使用的注意事项
查看>>
cisco 出现 %Error opening tftp://255.255.255.255 错误解决办法
查看>>
VIM编辑器
查看>>
IE主页被篡改 地址框变灰
查看>>
在交换机上配置Telent
查看>>
linux上架设l2tp+ipsec ***服务器
查看>>
jenkins pipeline dotnet 编译模板
查看>>
土木工程师资料管理系统EngineerCMS
查看>>
lua 简单实现 面向对象
查看>>
PHP与JSP的比较
查看>>