码上敲享录 > SpringBoot常见问题详解 > idea创建springboot项目打印hello world教程,太容易了

idea创建springboot项目打印hello world教程,太容易了

上一章章节目录下一章 2020-06-17已有1148人阅读 评论(0)

idea创建springboot项目打印hello world教程,太容易了


解决方法:

我的idea版本是ultimate2017.3版本,其他版本教程都差不多,最后改一下pom.xml文件就好了。

1.File--》New--》Project...--》Spring Initializr--》next--》修改一下Group和Artifact中的内容,也可以不改--》next--》弹框的顶部可以切换springboot的版本,在左边依赖列表中选择Web,在中间窗口选中Spring Web(有的idea是Spring Web Starter)。又回到左边的依赖列表中选择Template Engines,在中间窗口选中Thymeleaf作为页面引擎模板--》next--》Finish。


2.在启动类中添加测试方法index:

@SpringBootApplication

@Controller

public class SpringcloudApplication {

public static void main(String[] args) {

SpringApplication.run(SpringcloudApplication.class, args);

}

@RequestMapping("index")

public  String index(){

return "index";

}

}


3.在templates下创建index.html文件:

<!DOCTYPE html>

<html lang="en">

<head>

   <meta charset="UTF-8">

   <title>Title</title>

</head>

<body>

hello world

</body>

</html>


4.浏览器直接方法:http://localhost:8080/index即可,在浏览器就会显示:hello world


向大家推荐《Activiti工作流实战教程》:https://xiaozhuanlan.com/activiti
0

有建议,请留言!

  • *您的姓名:

  • *所在城市:

  • *您的联系电话:

    *您的QQ:

  • 咨询问题:

  • 提 交