功能:浏览器发送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. 安装vmware tools后仍然不能拖拽文件

    运行/usr/bin/vmware-user文件 ./vmware-user

  2. OpenShift 4.3环境中创建基于Go的Operator

    详细步骤可以参考官方文档 https://docs.openshift.com/container-platform/4.3/operators/operator_sdk/osdk-getting-s ...

  3. 在 linux 中连接 mysql 数据库

    命令格式 mysql -h主机地址 -u用户名 -p用户密码 登录本机 mysql mysql -u用户名 -p用户密码 实例 TD - X1数据库:/opt/lampp/bin/mysql -u r ...

  4. valign

    值 描述 top 对内容进行上对齐. middle 对内容进行居中对齐(默认值). bottom 对内容进行下对齐. baseline 与基线对齐.

  5. Unity中引入Supersocket.ClientEngine并测试

    在使用Supersocket Server的过程中,发现Server是不支持.net 3.5的. 1.Server端中的几个Command: namespace SuperSocketProtoSer ...

  6. IntelliJ IDEA 2017.3尚硅谷-----配置 Maven

  7. IntelliJ IDEA 2017.3尚硅谷-----鼠标悬浮提示

    建议不会的直接百度取消设置

  8. borderInterpolate()函数

    官网:borderInterpolate borderInterpolate 函数原型 int borderInterpolate( int p, int len, int borderType ); ...

  9. python自动化测试之生成BeautifulReport可视化测试报告

    用python写自动化测试时,unittest框架与BeautifulReport结合能够生成完美的可视化测试报告 [第一步]:准备好BeautifulReport,git地址: https://gi ...

  10. 洛谷 P5569 [SDOI2008]石子合并 GarsiaWachs算法

    石子合并终极通用版 #include<bits/stdc++.h> using namespace std ; ]; int n,t,ans; void combine(int k) { ...