Spring BootIT技术篇SpringBoot精选

Spring Boot--1.运行官网的入门程序

2017-02-12  本文已影响2563人  zlcook

编译运行Spirng Boot入门程序

clone github上的程序

Paste_Image.png

进入init目录

Paste_Image.png

编写代码

下载好的代码是编写完整的,不需要写。待会要访问的就是下面这个服务。

@RestController
public class HelloController {
    
    @RequestMapping("/")
    public String index() {
        return "Greetings from Spring Boot!";
    }
    
}

编译maven项目

pom.xml文件中使用的spring-boot-starter-parent是1.5.1-RELEASE版本,因为之前编译过一个1.4.3版本的所以我把它改成1.4.3.RELEASE了,这样就省的在下一个新的了。

mvn package 

中间出了些问题:下不到构件问题,使用的是nexus私服,最后解决了。
打包完在target目录下生成一个jar包。


Paste_Image.png

执行运行程序命令

java -jar target/gs-spring-boot-0.1.0.jar

运行成功

Paste_Image.png
打开浏览器输入http://localhost:8080
结果 Paste_Image.png
上一篇下一篇

猜你喜欢

热点阅读