springboot学习--第一个实例

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/nanruitao10/article/details/84401189

springboot入门实例

   创建自己的第一个实例hello World!,每一种学习的必学实例helloworld,使用的idea(自动第一次使用就喜欢上了)创建的

  1. new Project
  2. 点击next
  3. 可默认,也可以自己填写,点击next
  4. 选择web模块,点击next,创建完成,完成之后的目录如下
  5. 可直接运行,通过SpringApplication类中的main方法启动,是不是很简单(相对于spring启动之间需要配置一大堆的文件)

下面来看一下pom.xml文件中的依赖包:

     <dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
    </dependencies>

开始编写一个类Demo

@RestController
public class Demo {
	@RequestMapping("/hello")
	public String hello(){
		return "hello word!";
	}
}

启动项目

看到上面日志,就说明项目正常启动,下面在浏览器中输入:http://localhost:8080/hello

springboot的入门实例搞定收工,欢迎吐槽!

猜你喜欢

转载自blog.csdn.net/nanruitao10/article/details/84401189
今日推荐