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

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 就完成了
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容