需要添加一个类,然后写一个方法,注释使用RestController
@RestController
public class HelloWorld {
@RequestMapping("/")
public String sayHelloWorld(){
return "hello world!";
}
}
之后通过springApplicationMain中的类run启动即可
之后浏览器访问:http://127.0.0.1:8081/就可以看到hello world了
解释RestController注解的作用是返回json格式的数据
相关推荐
Spring Boot学习笔记-------(二)spring boot入门,配套例子代码,博客地址:https://blog.csdn.net/huaya1127/article/details/104130300
这个项目是一个基础的spring-boot整合项目,麻雀虽小,五脏俱全,先提供给需要的人。
- [spring-boot-helloWorld](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-helloWorld):Spring Boot 的 hello World 版本 - [spring-boot-web]...
spring-boot-hello:Spring Boot 2.0 Hello World 示例 spring-boot-banner:Spring Boot 定制 Banner 示例 spring-boot-docker:使用 Docker 部署 Spring Boot 示例 dockercompose-springboot-mysql-nginx :Docker...
博客文章示例代码: spring boot 自学笔记(一) hello word
spring-boot-helloWorld:spring-boot的helloWorld版本 spring-boot-mybaits-annotation:注解版本 spring-boot-mybaits-xml:xml配置版本 spring-boot-mybatis-mulidatasource:springboot+mybatis多数据源最简解决...
helloworld|[spring mvc,Spring Boot项目创建,单元测试](https://github.com/smltq/spring-boot-demo/blob/master/helloworld/HELP.md) web|[ssh项目,spring mvc,过滤器,拦截器,监视器,thymeleaf,lombok,jquery,...
spring-boot-hello-world Spring Boot 应用程序示例
server','springboot-elasticsearch','springboot-freemarker','springboot-helloworld','springboot-mybatis','springboot-mybatis-annotationspringboot-mybatis-annotation','springboot-mybatis-mutil-...
【42】使用dubbo、spring-boot等技术实现互联网后台服务项目架构视频教程 .txt
springboot的入门小程序,idea下的,亲测可用。请仔细阅读注释
spring-boot-helloWorld:spring-boot的helloWorld版本 spring-boot-mybaits-annotation:注解版本 spring-boot-mybaits-xml:xml配置版本 spring-boot-mybatis-mulidatasource:springboot+mybatis多数据源最简...
Spring Boot 学习示例 Spring Boot 2.0 Mysql 5.6 ...spring-boot-helloworld:Spring Boot 3.0 Hello World Test 单元测试示例 spring-boot-scheduler:Spring Boot 3.0 定时任务 scheduler 使用示例 .....
helloworld-spring-boot-starter 自定义starter代码及测试函数...
第 1-4 课:写一个 Hello World 来感受 Spring Boot/hello 第 2-1 课: Spring Boot 对基础 Web 开发支持/spring-boot-web 第 2-10 课: 使用 Spring Boot WebSocket 创建聊天室/spring-boot-websocket 第 2-2 课...
01-spring-boot-helloWorld //调度器 02-spring-boot-banner//springboot标识广告 03-spring-boot-scheduler//任务调度器 04-spring-boot-mybatis-xml//mybaist-xml方式 05-spring-boot-logback//默认logback日志...
博客示例代码,Spring boot 自学笔记(一) hello world 代码
<groupId>org.springframework.boot <artifactId>spring-boot-starter-parent <version>2.1.4.RELEASE <relativePath/> <!-- lookup parent from repository --> <groupId>com.example</groupId> ...
:spring-boot的helloWorld版本 :注解版本 :xml配置版本 spring-boot-mybatis-mulidatasource:springboot+mybatis多数据源最简解决方案 spring-boot-mybatis-annotation-mulidatasource:springboot+mybatis...
Spring Boot应用程序样本 该示例Spring Boot应用程序是为博客文章编写的,该博客文章描述了如何使用IntelliJ创建Spring Boot应用程序。