SpringBoot入门(一) springBoot框架搭建和启动

短命女 2022-05-29 04:00 375阅读 0赞

1.创建maven工程 Maven Project

  1. ![Image 1][]

![Image 1][]

//CODE

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  2. <modelVersion>4.0.0</modelVersion>
  3. <groupId>com.spb.one</groupId>
  4. <artifactId>spb-one</artifactId>
  5. <version>1.0</version>
  6. <parent>
  7. <groupId>org.springframework.boot</groupId>
  8. <artifactId>spring-boot-starter-parent</artifactId>
  9. <version>1.5.10.RELEASE</version>
  10. </parent>
  11. <dependencies>
  12. <dependency>
  13. <groupId>org.springframework.boot</groupId>
  14. <artifactId>spring-boot-starter-web</artifactId>
  15. </dependency>
  16. </dependencies>
  17. </project>
  18. package hello;
  19. import org.springframework.boot.*;
  20. import org.springframework.boot.autoconfigure.*;
  21. import org.springframework.stereotype.*;
  22. import org.springframework.web.bind.annotation.*;
  23. @Controller
  24. @EnableAutoConfiguration
  25. public class SampleController {
  26. @RequestMapping("/")
  27. @ResponseBody
  28. String home() {
  29. return "Hello World!";
  30. }
  31. public static void main(String[] args) throws Exception {
  32. SpringApplication.run(SampleController.class, args);
  33. }
  34. }

//运行结果

  1. ![Image 1][]

//访问spring官方第一个springBoot工程

  1. ![Image 1][]

[Image 1]:

发表评论

表情:
评论列表 (有 0 条评论,375人围观)

还没有评论,来说两句吧...

相关阅读