欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

一步一步教你在IEDA中快速搭建SpringBoot项目

发布时间:2025/3/19 44 豆豆
生活随笔 收集整理的这篇文章主要介绍了 一步一步教你在IEDA中快速搭建SpringBoot项目 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

场景

IEDA 2017

现在要在IDEA中搭建SpringBoot项目快速输出HelloWorld。

实现

打开IEDA,点击File--new--project

选择左边的Spring Initializr,注意右边这里默认是1.8,其他不变,点击next。

编写Group、Artifact,这里使用默认的,点击next。

点击左边Web,然后勾选右边Web,点击Next。

设置好项目名以及项目路径,点击Finish。

点击FInish后会进行下载一些资源文件。

 

建完成后的目录如下

在项目下新建包

 

新建包之后

在新建的包下面新建controller。

 

建成之后的Controller如下

修改其代码为:

package com.example.demo.controller; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RequestMapping; /*** Created by BADAO on 2019/2/19.*/ @RestController public class TestController {@RequestMapping("/test")public  String hello(){System.out.print("Hello Spring Boot!!!!!!!");return  "I am Idea!!!!";} }

打开Application

修改其代码为:

package com.example.demo;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @SpringBootApplication @EnableAutoConfiguration public class DemotestApplication {public static void main(String[] args) {SpringApplication.run(DemotestApplication.class, args);}}

右击Application,运行

运行后输出如下

打开浏览器,输入:

http://localhost:8080/test

可以看到控制台输出

而浏览器会显示

 

总结

以上是生活随笔为你收集整理的一步一步教你在IEDA中快速搭建SpringBoot项目的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。