搭建一个 简单的 spring boot 工程

这几天学习了spring boot的系统搭建, 总结一下这几天遇到的问题,记录下来作为备忘。

第一步: new project

第二步: 选择Spring Initializr

在此一步,我刚开始无法连接到start.spring.io ,无论选择default或者custom,最后找到需要设置一下代理,具体方式如下: 

 

第三步:点击next ,然后改成你自己喜欢的名字

 第四步,选择需要的插件

developer tools -》spring boot DevTools    Web-->Spring Web  为了方便测试  选择 Template Engines-->Thymeleaf 

第五步,起一个工程名,比如:springbootdemo

 

 

然后点击finish ,ok  项目建成了。

 

第六步,测试 

1.新建一个Action , 

@Controller
public class IndexController {
    @RequestMapping("/showIndex")
    public String getIndex(Model model){
        model.addAttribute("name", "thymeleaf");
    return "index";
}

}

2.然后在 resources->templates中新建一个html,然后里面写着hello  spring boot 

<html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>index</title>
</head>
<body>
<h1>hello spring boot</h1>
<p th:text="hello spring boot"></p>
</body>
</html>

 

3.直接run这个工程,

@SpringBootApplication
public class SpringbootdemoApplication {

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

}

4.访问url http://localhost:8080/showIndex

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值