spring boot 第一个demo

只是简单的构建。

1.下载:从https://spring.io/projects/spring-boot --> Quick start 下载Demo.zip

2. 搭建:任意新建workplace import  Exiting Maven Projects。

3. 增加依赖:pom.xml下dependencies增加spring-boot-starter-web依赖。(run Maven install)

4. 添加测试代码。

@RestController

public class HelloController { 

    @RequestMapping(value="/hello", method=RequestMethod.GET) 

    public String HelloController() { 

        return "Hello World!"; 

    } 

}

5. 测试:http://localhost:8080/hello 正常就返回Hello World!。


sagan :一定要git clone 不要download.txt。

项目从官网跳转github下载。

initializr:import所有,直接运行InitializrService,成功后打 localhost:8080/ 会有网页

注:

initializr

pom会报

Plugin execution not covered by lifecycle configuration:

io.spring.javaformat:spring-javaformat-maven-plugin:0.0.6:validate (execution: default, phase: validate)

不用管。。可以直接运行,编辑器提示而已。


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容