美文网首页程序员Spring-Boot
【Spring Boot 从入门到放弃】Hello World

【Spring Boot 从入门到放弃】Hello World

作者: 路西法Lucifer丶 | 来源:发表于2018-03-26 14:30 被阅读0次
    File-->New-->Project-->Spring Initializr 点击next
    image.png
    填写Artifact项目名称
    image.png
    勾选Web 这里标识了spring boot版本号 2.0.1 3月1号发布 aliyun等第三方镜像还没有包 需要到spring.io/下载 很慢 所以选择用1.51版本
    image.png
    修改项目地址 点击Finish
    image.png
    项目结构
    image.png
    新建一个TestController
    package com.example;  
      
    import org.springframework.web.bind.annotation.RequestMapping;  
    import org.springframework.web.bind.annotation.RestController;  
      
    @RestController  
    public class HelloController {  
      
        @RequestMapping("/hello")  
        public String hello() {  
            return "hello world";  
        }  
    }  
    
    找到程序自动生成的XychwlApplication,会有一个@SpringBootApplication的注解,这个注解用来标明这个类是程序的入口,在main方法上右键,点击Run XychwlApplication
    image.png
    出现端口号 项目启动成功
    image.png
    测试:

    在地址栏中输入http://localhost:8080/hello

    image.png
    到此以上 hello world 就完成了

    相关文章

      网友评论

        本文标题:【Spring Boot 从入门到放弃】Hello World

        本文链接:https://www.haomeiwen.com/subject/gckrcftx.html