第一个SpringBoot

Posted shiyi201106

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第一个SpringBoot相关的知识,希望对你有一定的参考价值。

第一个SpringBoot应用

在这里我选择的开发工具是IntelliJ IDEA  企业版。

在开发前,你需要把环境都装好,Maven,JDK。

按照下面的图片步骤,即可建好一个helloword项目了。

技术分享图片

技术分享图片

技术分享图片 
勾选中web选项的web

技术分享图片 
这三个目录和文件没什么用,你可以删除。 
第一次建springBoot项目可能需要时间有点久,别急,在下载jar包呢。

新建一个类: 
技术分享图片

package cn.chenhaoxiang;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * User: xxx
 * Date: xxxx/xx/xx.
 * Time: 下午 xx:xx.
 * Explain:
 */
@RestController
public class HelloController {
    @RequestMapping(value = "/hello",method = RequestMethod.GET)
    public String say() {
        return "Hello Spring Boot!";
    }
}

启动方式

1. IDEA直接启动
2. CMD, 切换到项目路径下 启动 : 1. mvn spring-boot run
        2. mvn install -> 切换至target目录下 java -jar ***-0.0.1-SNAPSHOT.jar









以上是关于第一个SpringBoot的主要内容,如果未能解决你的问题,请参考以下文章