SpringBoot之hello world

从C++到JAVA,所学的第一个程序都是hello world!

我决定学习Springboot也从hello world 开始.

https://www.cnblogs.com/ityouknow/p/5662753.html 

这篇文章非常好,学习一下.

1.  打开 http://start.spring.io/  选 择maven java springboot 2.0.1 直接gennerate

 

2. 使用eclipse,Import -> Existing Maven Projects -> Next ->选择解压后的文件夹-> Finsh,OK done!

项目结构如下

 

3.点击pom.xml

  默认有两个jar包,需要手动引用spring-boot-starter-web.jar

4.新建HelloWorld.java

package com.example.demo;

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

@RestController
public class HelloWorldController {
    
    @RequestMapping("/helloworld")
    public String helloworld() {
        return "hello world!";
    }
}

 

5.对着DemoApplication.java 点右键,run as --spring boot

6.浏览器访问 http://localhost:8080/helloworld

 

posted on 2018-04-12 17:44  Junqiang  阅读(197)  评论(0编辑  收藏  举报

导航