第一个Springboot程序

1.新建一个maven空项目

2.修改pom.xml文件

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.lamoun</groupId>
    <artifactId>springboot_demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>springboot_demo</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

3.编写启动类MyApplication

1 @SpringBootApplication
2 public class MyApplication {
3 
4     public static void main(String[] args) {
5         SpringApplication.run(MyApplication.class);
6     }
7 }

4.编写Controller

1 @RestController
2 public class MyController {
3 
4     @RequestMapping("/demo")
5     public String fun1(){
6         return "hello world!";
7     }
8 }

5.启动成功

 

6.浏览器访问

 

posted on 2021-02-22 10:13  阿基的米德  阅读(35)  评论(0)    收藏  举报