功能:浏览器发送hello请求,服务器接收请求并处理,返回hello word字符串

一、创建一个maven项目

二、在pom.xml文件中添加依赖导入springboot框架运行需要的依赖

     <!-- 继承了一个父项目 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> <dependencies>
<!-- web模块的依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>

三、编写一个主程序,自动Springboot

具体启动代码如下:

 /**
* @SpringBootApplication 主程序类的标注
*/
@SpringBootApplication
public class HelloWordMainApplication {
//main方法快捷键是 psvm
public static void main(String[] args) {
//spring boot 应用启动起来,
SpringApplication.run(HelloWordMainApplication.class,args);
}
}

四、编写相关的controller,service

  • 新建一个controller类

  • 具体代码如下

     @Controller
    public class HelloController { @ResponseBody //把接口返回的结果写在浏览器上
    @RequestMapping("/hello") //接收来自浏览器的hello请求
    public String hello(){
    return "Hello Word";
    }
    }

五、启动main程序,在浏览器中打开http://localhost:8080/hello 测试结果,结果返回如下

springboot 框架 - helloword的更多相关文章

  1. Springboot框架

    本片文章主要分享一下,Springboot框架为什么那么受欢迎以及如何搭建一个Springboot框架. 我们先了解一下Springboot是个什么东西,它是干什么用的.我是刚开始接触,查了很多资料, ...

  2. Springboot 框架学习

    Springboot 框架学习 前言 Spring Boot是Spring 官方的顶级项目之一,她的其他小伙伴还有Spring Cloud.Spring Framework.Spring Data等等 ...

  3. 小程序后端项目【Springboot框架】部署到阿里云服务器【支持https访问】

    前言: 我的后端项目是Java写的,用的Springboot框架.在部署服务器并配置https访问过程中,因为做了一些令人窒息的操作(事后发现),所以老是不能成功. 不成功具体点说就是:域名地址可以正 ...

  4. springBoot框架的搭建

    1新建一个项目: 2.注意选择JDK1.8,和选择spring initializr加载springBoot相关jar包: 3.下一步next: 4.下一步next,选择Web和MyBatis然后ne ...

  5. 纯手写SpringMVC到SpringBoot框架项目实战

    引言 Spring Boot其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置. 通过这种方式,springboot ...

  6. 快速搭建springboot框架以及整合ssm+shiro+安装Rabbitmq和Erlang、Mysql下载与配置

    1.快速搭建springboot框架(在idea中): file–>new project–>Spring Initializr–>next–>然后一直下一步. 然后复制一下代 ...

  7. SpringBoot框架的权限管理系统

    springBoot框架的权限管理系统,支持操作权限和数据权限,后端采用springBoot,MyBatis,Shiro,前端使用adminLTE,Vue.js,bootstrap-table.tre ...

  8. SpringBoot 框架整合

    代码地址如下:http://www.demodashi.com/demo/12522.html 一.主要思路 使用spring-boot-starter-jdbc集成Mybatis框架 通过sprin ...

  9. Springboot框架中request.getInputStream()获取不到上传的文件流

    Springboot框架中用下面的代码,使用request.getInputStream()获取不到上传的文件流 @PostMapping("/upload_img") publi ...

随机推荐

  1. crontab定时的使用

    //查看所有定时 crontab -l修改$ crontab -e //增加定时 //关闭定时 //删除定时$ crontab -r /sbin/service crond start //启动服务 ...

  2. Java中数字的格式化输出

    Java中数字的格式化输出 double d = 345.678; String s = "hello!"; int i = 1234; //"%"表示进行格式 ...

  3. 通过css修改input的边框

    input{ border:1px solid #d2d2d2; background-color:transparent; } 可以看到主要是把背景色调成透明的颜色,从而来进行边框的设置

  4. 【PAT甲级】1115 Counting Nodes in a BST (30分)(二叉查找树)

    题意: 输入一个正整数N(<=1000),接着输入N个整数([-1000,1000]),依次插入一棵初始为空的二叉排序树.输出最底层和最底层上一层的结点个数之和,例如x+y=x+y. AAAAA ...

  5. 转载:Cubic interpolation

    https://www.paulinternet.nl/?page=bicubic Cubic interpolation If the values of a function f(x) and i ...

  6. t-SNE

    Don't look back. Don't hesitate, just do it. t-SNE原理 from here. 1. tsne is strictly used for visuali ...

  7. SVN提交时没有写注释

    会报错: Error: Commit blocked by pre-commit hook (exit code 1) with output: Error: [Commit failed]: Emp ...

  8. IN中超过1000处理

    后台 所有用到IN的方法,都要考虑超过1000的可能 if(cameraIds != null && cameraIds.length > 0){sql.append(" ...

  9. 利用python装饰器为字符串添加,HTML标签

    # 为字符串添加HTML标签 import time def zhuang(fun): def zhaung_1(*args, **kargs): # time.sleep(1) html_str = ...

  10. ignoreContentAdaptWithSize

    使用cocosStudio 中 的Text控件时,要设定text.ignoreContentAdaptWithSize(true); 设定控件(0.5,0.5)锚点位置不随文本长度变化而变化.