Spring Boot: Building a RESTful Web Service
来源:互联网 发布:淘宝广告商品被删 编辑:程序博客网 时间:2024/05/20 14:16
1、@RestController:
which marks the class as a controller where every method returns a domain object instead of a view. It’s shorthand for @Controller and @ResponseBody rolled together.
2、在springBoot的controller中返回一个对象,不需要手动转换为json,因为会自动转换:
Because Jackson 2 is on the classpath, Spring’s MappingJackson2HttpMessageConverter is automatically chosen to convert the Greeting instance to JSON.
3、@SpringBootApplication注解综合了如下几个注解的功能
@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.(注意:这里的英文注释中hello这个包,是springBoot的main方法中使用@SpringBootApplication注解类所在的包,也就是说,会自动扫描,但是只会扫描此包下以及子包下的类,所有会报错)
4、Build an executable JAR
- 如何将项目打包为一个jar文件:If you are using Maven, you can run the application using mvn spring-boot:run. Or you can build the JAR file with mvn clean package,Then you can run the JAR file:
java -jar target/gs-rest-service-0.1.0.jar
- Spring Boot: Building a RESTful Web Service
- Spring Building a RESTful Web Service
- Building a RESTful Web Service
- Building a RESTful Web Service
- Building a RESTful Web Service
- Spring Boot 之 Consuming a RESTful Web Service
- SpringBoot 之 Building a RESTful Web Service
- Spring Boot 创建RESTful Web Service
- Spring Boot创建一个RESTful Web Service
- How To Start An Spring Application-Building a RESTful Web Service
- 教程学习 01-Building a RESTful Web Service 学习笔记
- 构建一个RESTful Web Service(Building a RESTful Web Service)
- 构建一个RESTful Web Service(Building a RESTful Web Service)
- spring boot demo( 获取一个RESTful web service)
- Spring Boot、Mybatis框架整合开发Java RESTful Web Service
- 使用spring boot快速构建一个RESTful Web Service
- 快速搭建RESTful Web Service(Spring Boot)
- Spring Boot示例 - 1. 使用Spring Boot Actuator构建RESTful web service
- QueryDsl查询mongodb数据1
- 吴恩达机器学习——我的错题集(持续更新)
- Ribbon负载均衡策略配置
- 自动关机HTA桌面小程序实现源码
- iOS的UILabel设置居上对齐,居中对齐,居下对齐
- Spring Boot: Building a RESTful Web Service
- react_basic(3)
- 《Effective C++》条款25:考虑写出一个不抛异常的swap函数
- QoS/ToS/CoS/DSCP 介绍
- 乃奎斯特采样定理的理解及应用实例
- php实现websocket实时消息推送
- Sap中动态内表的使用
- 好累
- 安装Linux操作系统(2)