准备工作:1、Intellij IDEA (ULTIMATE版):官网下载地址 https://www.jetbrains.com/idea/download/#section=windows2、JDK 一、创建新项目 二、左侧面板选择Spring Initializ ...
准备工作:
1、Intellij IDEA (ULTIMATE版):官网下载地址 https://www.jetbrains.com/idea/download/#section=windows
2、JDK
一、创建新项目
二、左侧面板选择Spring Initializr
输入项目名称,项目组名称和项目ID,点击进入下一步
下面的页面是用于添加依赖的,可以根据需求,添加依赖。或者在pom.
当前测试只需勾选 Web。
点击Next,项目创建结束。项目架构如下所示:(注:Example.java是我添加的)
二、在相应目录下创建 Example.java。代码如下:
package com.example.demo;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.boot.autoconfigure.EnableAutoConfiguration;import org.springframework.web.bind.annotation.PathVariable;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;@RestController@EnableAutoConfigurationpublic class Example { @RequestMapping("/") String home() { return "Hello World!"; } @RequestMapping("/hello/{myName}") String index(@PathVariable String myName) { return "Hello "+myName+"!!!"; }}
原标题:SpringBoot入门第一章:Hello World
关键词:Spring
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。