温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Intellij IDEA如何创建spring-boot项目

发布时间:2021-06-07 11:22:53 来源:亿速云 阅读:178 作者:小新 栏目:编程语言

这篇文章将为大家详细讲解有关Intellij IDEA如何创建spring-boot项目,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

开发环境:

  • jdk版本:JDK8 

  • maven版本:maven-3.5.2  

  • 开发工具:Itellij IDEA 2017.1

前提条件:已安装以上软件并配置好jdk和maven的环境变量

创建步骤:

点击坐上角file ---》选择new ---》点击project... 如下图所示:

Intellij IDEA如何创建spring-boot项目

点击左边Spring Initializr ---》 右上角新建jdk(若有则不需要) ---》 点击next 如下图所示:

Intellij IDEA如何创建spring-boot项目

看需求修改下图中的信息后点击next(可以直接使用默认)

Intellij IDEA如何创建spring-boot项目

点击左边的Web ---》 选中中间列的Web ---》 点击next 如下图所示:

Intellij IDEA如何创建spring-boot项目

输入项目名称和保存路径 --- 》点击finish

Intellij IDEA如何创建spring-boot项目

创建的项目如下图所示:

Intellij IDEA如何创建spring-boot项目

创建HelloController类,代码如下所示:

package com.example.demo.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/hello")
public class HelloController {
 @RequestMapping("/say")
 public String sayHello() {
  return "hello world";
 }
}

执行DemoApplication中main方法后访问http://localhost:8080/hello/say 页面如下所示:

Intellij IDEA如何创建spring-boot项目

关于“Intellij IDEA如何创建spring-boot项目”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI