码迷,mamicode.com
首页 > 编程语言 > 详细

2.springboot:快速创建springboot项目

时间:2020-01-23 22:39:01      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:命名   http   主程序   void   gap   嵌入式   浏览器   span   ati   

 使用IDEA快速创建springboot项目流程:

 

 创建新的项目选择

 技术图片

 

 

项目的命名以及包名

技术图片

 

 

 需要什么包就导入什么包

技术图片

 

 

进行测试的单元

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

 

 

此时的工程默认有这个启动的主程序

技术图片

 

 

Springboot01Application.java
@SpringBootApplication
public class Springboot01Application {
    public static void main(String[] args) {
        SpringApplication.run(Springboot01Application.class, args);
    }
}

 

新建一个controller包和controller类:

//此时类的所有方法都会返回数据给浏览器(对象是专为json)
//@RestController  = @ResponseBody + @Controller
@ResponseBody
@Controller
public class Helloword {
    @RequestMapping("/hello")
    public  String hello(){

        return "Hello tow!";
    }
}

 

 运行访问:

技术图片

 

 

 springboot工程结构:

技术图片

 

 

static文件夹:保存所有的静态资源
templates文件夹:保存所有的模板页面(Springboot默认jar使用嵌入式的Tomcat,默认不支持jsp页面);可以使用模板引擎
application.properties:springboot应用的配置文件

2.springboot:快速创建springboot项目

标签:命名   http   主程序   void   gap   嵌入式   浏览器   span   ati   

原文地址:https://www.cnblogs.com/lyh233/p/12231433.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!