首页 > 编程语言 > 详细

spring boot hello world 搭建

时间:2017-07-23 18:50:09      阅读:252      评论:0      收藏:0      [点我收藏+]

 

1.下载地址:

Eclipse:http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/neonr

Spring Tool Suite:https://spring.io/tools/sts/all

 

2.使用版本为:

Eclipse:eclipse-jee-neon-R-win32-x86_64.zip

Spring Tool Suite:springsource-tool-suite-3.9.0.RELEASE-e4.6.3-updatesite.zip

 

2.插件安装:

  采用离线安装,安装方式类似svn的安装。

 

3.新建工程:

技术分享

 

注意,过程中选择相应的组件,如web,mybatis,redis 等。

 

4.hello World 代码的编写

 共两个类。

类1:

package com.example.first;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;  
import org.springframework.web.bind.annotation.PathVariable;  
import org.springframework.web.bind.annotation.RequestMapping;  
import org.springframework.web.bind.annotation.RestController;  
  
@RestController  
@EnableAutoConfiguration  
public class Example {  
      
    @RequestMapping("/")  
    String home() {  
        return "Hello World!";  
    }  
      
    @RequestMapping("/hello/{myName}")  
    String index(@PathVariable String myName) {  
        return "Hello "+myName+"!!!";  
    }  
}  


类 2:

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

 

5.启动方式

  右键项目名称,run as application ,选择上面的Application 类。

 浏览器输入 http://localhost:8080/   即可看到  Hello World!

 

spring boot hello world 搭建

原文:http://www.cnblogs.com/xzzq/p/7225470.html

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