版权声明:版权没有,盗用不究 https://blog.csdn.net/liman65727/article/details/81912655
前言
不管从哪方面来说,自学一些内容都是必须的,现在行里用的较多的spring boot之前一直想学,但是因为毕业论文和毕业设计的关系被耽误到现在,在完成了相关开发工作的余下时间可以自学一些东西,思来想去,觉得现在就是学习spring boot的最好时间,于是就开始了
spring boot项目的搭建
这里不会做过多的概念解释,直接进行一些实际操作。
spring boot的搭建
1、使用maven构建
不需要自己手动建立maven项目,直接在https://start.spring.io/中输入相关参数后即可创建项目,然后将项目下载下来,导入IDE即可
由于无法在内网中进行开发,因此这里只能选用eclipse进行操作。
2、编写相关业务代码示例
直接创建相应的包并编写Controller即可,使用@RestController标签标注Controller即可
package com.learn.web;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.learn.component.BlogProperties;
@RestController
public class HelloController {
@Autowired
private BlogProperties blogProperties;
@RequestMapping("/hello")
@ResponseBody
public String index() {
System.out.println(blogProperties.getJob());
System.out.println(blogProperties.getCompany());
return "hello world";
}
}
3、测试helloworld
启动之后,直接输入localhost:8080/hello即可
总结
整个操作只需要几分钟即可搞定