在IDEA中创建SpringBoot项目01
Posted hello,vicme!
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在IDEA中创建SpringBoot项目01相关的知识,希望对你有一定的参考价值。
1.选择创建项目
2.填写项目信息
3.
4.
5.Finish后会下载,之后生成目录结构:
6.在自己的包目录结构下添加了Controllr和Entiy测试项目:
Controller:
1 package com.hwl.graduation.controller; 2 3 import com.hwl.graduation.entity.People; 4 import org.springframework.stereotype.Controller; 5 import org.springframework.web.bind.annotation.RequestMapping; 6 import org.springframework.web.bind.annotation.ResponseBody; 7 8 @Controller 9 public class PersonController { 10 11 @ResponseBody 12 @RequestMapping(value="/getPeople") 13 public People getPeople() { 14 return new People("菜鸟",20,"男"); 15 } 16 }
Entity:
1 package com.hwl.graduation.entity; 2 3 public class People { 4 private String name; 5 private int age; 6 private String sex; 7 8 @Override 9 public String toString() { 10 return "People [name=" + name + ", age=" + age + ", sex=" + sex + "]"; 11 } 12 13 public People() { 14 super(); 15 } 16 17 public People(String name, int age, String sex) { 18 super(); 19 this.name = name; 20 this.age = age; 21 this.sex = sex; 22 } 23 24 public String getName() { 25 return name; 26 } 27 28 public void setName(String name) { 29 this.name = name; 30 } 31 32 public int getAge() { 33 return age; 34 } 35 36 public void setAge(int age) { 37 this.age = age; 38 } 39 40 public String getSex() { 41 return sex; 42 } 43 44 public void setSex(String sex) { 45 this.sex = sex; 46 } 47 48 }
7.运行项目,浏览器访问成功:
以上是关于在IDEA中创建SpringBoot项目01的主要内容,如果未能解决你的问题,请参考以下文章
185-在idea中创建springboot项目启动时出现java.lang.NoClassDefFoundError: ch/qos/logback/core/spi/LifeCycle错误(示例代