springboot快速入门

首先,建立一个空的项目

springboot-helloworld实现

第二步:

建立一个springboot项目

springboot-helloworld实现

 

 第三步:添加依赖:

<?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>com.leyou.demo</groupId>
    <artifactId>springboot-demo</artifactId>
    <version>1.0-SNAPSHOT</version>

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

    <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>
</project>

  第四步:编写控制器

package com.java.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author nidegui
 * @create 2019-05-26 10:15
 */
@Controller
public class HelloController {

    /**
     *
     * @return
     */
    @ResponseBody
    @RequestMapping("/hello")
    public String hello(){
        return  "springboot-nihao";
    }
}

  第五步:启动application

springboot-helloworld实现

第六步:访问

springboot-helloworld实现

 

相关文章:

  • 2021-06-01
  • 2021-04-25
  • 2021-09-05
  • 2021-06-21
  • 2022-01-12
  • 2021-04-24
  • 2021-12-14
猜你喜欢
  • 2021-10-12
  • 2021-07-02
  • 2022-12-23
  • 2021-06-01
  • 2021-08-10
  • 2021-09-03
  • 2021-08-07
相关资源
相似解决方案