转载自:https://www.cnblogs.com/wmyskxz/p/9010832.htmlcss
选择 Spring Initializr ,而后选择默认的 url 点击【Next】:html
而后修改一下项目的信息:web
勾选上 Web 模板:spring
选择好项目的位置,点击【Finish】:springboot
若是是第一次配置 Spring Boot 的话可能须要等待一下子 IDEA 下载相应的 依赖包,默认建立好的项目结构以下:服务器
项目结构仍是看上去挺清爽的,少了不少配置文件,咱们来了解一下默认生成的有什么:app
在【cn.wmyskxz.springboot】包下新建一个【HelloController】:ide
package cn.wmyskxz.springboot; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * 测试控制器 * * @author: @我没有三颗心脏 * @create: 2018-05-08-下午 16:46 */ @RestController public class HelloController { @RequestMapping("/hello") public String hello() { return "Hello Spring Boot!"; } }
咱们回到 SpringbootApplication 这个类中,而后右键点击运行:spring-boot
等待一下子就会看到下方的成功运行的提示信息:测试
能够看到咱们的 Tomcat 运行在 8080 端口,咱们来访问 “/hello
” 地址试一下:
能够看到页面成功显示出咱们返回的信息。