idea环境下springboot学习(一)(helloword项目)

1、说在前面的话

       以前用过ssm框架来开发项目,确实比jsp+servlet的开发方式简单太多,所以在技术方面要与时俱进,不断的学习。废话不多说,直接分享经验,自勉。

2、springboot简介

个人认为可以将springboot看成是ssm的升级版,抛弃了繁琐的xml配置过程,采用大量的默认配置简化我们的开发过程.

3.动手

3.1  新建project

3.2  选中Spring Initializr。

ps:Spring initializr 是Spring 官方提供的一个用来初始化一个Spring boot 项目的工具。

idea环境下springboot学习(一)(helloword项目)

idea环境下springboot学习(一)(helloword项目)

idea环境下springboot学习(一)(helloword项目)

idea环境下springboot学习(一)(helloword项目)

3.3  第一次开发springboot项目,maven的构建比较慢耐心等待jar包的自动下载。完成之后项目结构如下:

idea环境下springboot学习(一)(helloword项目)

3.4  idea自动生成了项目启动类

idea环境下springboot学习(一)(helloword项目)

3.5  此时我们还需要创建一个controller即可运行

使用@RestController标签来代替@Controller[email protected]注解,如果注解报错。原因是没导入相关jar包,alt+enter快捷键,选择添加spring-boot-starter-web,让maven自动下载

idea环境下springboot学习(一)(helloword项目)

3.6  在控制器里面编写一个方法,然后运行项目

idea环境下springboot学习(一)(helloword项目)

idea环境下springboot学习(一)(helloword项目)

测试通过。