最基本的,官网copy

创建maven项目

maven中添加

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.2.RELEASE</version>
    </parent>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

创建一个类

@Controller
@EnableAutoConfiguration
public class SampleController {

    @RequestMapping("/")
    @ResponseBody
    String home() {
        return "Hello World!";
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(SampleController.class, args);
    }
}

运行该方法

1、springboot之HelloWorld

然后浏览器中输入http://localhost:8080/

1、springboot之HelloWorld

输出Hello World!说明springboot已经成功启动。

 

相关文章:

  • 2021-09-19
  • 2021-11-25
  • 2021-08-06
  • 2022-01-13
  • 2021-08-07
  • 2021-10-03
  • 2021-11-19
猜你喜欢
  • 2021-10-18
  • 2021-04-16
  • 2022-01-29
  • 2021-07-02
  • 2022-12-23
相关资源
相似解决方案