首页 > 编程语言 > 详细

SpringBoot快速开始

时间:2020-06-20 14:35:50      阅读:56      评论:0      收藏:0      [点我收藏+]

用maven创建第一个SpringBoot项目

一、创建maven项目

技术分享图片

 

 技术分享图片

 

 技术分享图片

 

二、添加springboot的maven依赖

<?xml version="1.0" encoding="UTF-8"?>
<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">
    <modelVersion>4.0.0</modelVersion>

    <groupId>muyer-springboot</groupId>
    <artifactId>quickStart</artifactId>
    <version>1.0-SNAPSHOT</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
    </parent>

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

三、创建相关类和配置文件

1.创建启动类

@SpringBootApplication
public class QuickStartpApp {
    public static void main(String[] args) {
        SpringApplication.run(QuickStartpApp.class,args);
    }
}

2.创建controller

@RestController
public class HelloSpringBoot {
    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public String helloSpringBoot() {
        return "hello springboot";
    }
}

3.创建配置文件

server.port=8090

4.类在项目中的结构

技术分享图片

 

 四、启动测试

1.点击启动类左边的启动按钮

2.浏览器输入请求地址:http://localhost:8090/hello

 

 技术分享图片

 

SpringBoot快速开始

原文:https://www.cnblogs.com/yejiang/p/13168318.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!