SpringBoot入门程序

 时间:2024-11-18 11:50:11

1、创建一个Maven工程:

SpringBoot入门程序

2、导入SpringBoot相关的依赖包:<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.0.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>

SpringBoot入门程序

4、编写相关的Controller、Service。package com.gwolf.controller;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;@Controllerpublic class HelloController { @ResponseBody @RequestMapping("/hello") public String hello() { return "hello World!"; }}

SpringBoot入门程序

6、在浏览器中访问地址:http://localhost:8080/hello

SpringBoot入门程序
  • 身在外地工作,如何关爱孝敬父母
  • 买了中兴股票怎么办
  • 如何在Keynote中设置图表的排列次序
  • Mac下PDF处理
  • 热门搜索
    旅游包 抚州旅游 夏天适合去哪里旅游 奉化旅游 新马泰旅游 西沙旅游 旅游英语口语300句 约伴旅游网 韶关旅游景点 广州旅游必去景点