springboot快速入门

springboot快速入门

springboot是对spring的封装,基于约定大于配置的思想。SpringBoot要求,项目要继承SpringBoot的起步依赖spring-boot-starter-parent也就是在创建springboot工程的时候,所有的项目都需要依赖parent。

  1. 创建maven项目
  2. 添加springboot的起步依赖
java 复制代码
 <parent>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-starter-parent</artifactId>
 <version>2.0.1.RELEASE</version>
 </parent>
  1. 集成springmvc对controller层的开发,引入对web的起步依赖
java 复制代码
   <dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-web</artifactId>
   </dependency>
  1. 编写引导类,使用@SpringBootApplication注解注明引导类
java 复制代码
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class QuickStartApplication {
    public static void main(String[] args) {
        SpringApplication.run(QuickStartApplication.class, args);
    }
}
  1. 启动springboot项目
相关推荐
不定积分要+C_yyy4 分钟前
Java关键字final三种用法、核心特性与高频易错点
java·开发语言
xexpertS1 小时前
队列积压治理:如何避免异步系统出现难以恢复的消息积压
java·开发语言
阿维的博客日记10 小时前
MultipartFile 是不是表示仅仅是一个分片?
java·后端·spring·multipartfile
程序员无隅10 小时前
Coding Agent 为什么压缩上下文后还能继续工作?上下文模块设计拆解
java·开发语言·数据库
Python+9910 小时前
Java 枚举类(Enum)详解:从基础到高级应用
java·开发语言·python
二炮手亮子10 小时前
浅记java线程池
java·开发语言
一路向北North10 小时前
Spring Security OAuth2.0(23):分布式系统授权-转发明文给微服务
java·spring·微服务
爱吃牛肉的大老虎12 小时前
rust基础之环境搭建
java·开发语言·rust
tellmewhoisi13 小时前
多版本共用redis的token有效期校验(过期重新登录)
java·redis·缓存
疯狂打码的少年13 小时前
【软件工程】结构化设计:模块独立性与耦合内聚
java·开发语言·笔记·软件工程