SpringBoot—手动创建demo项目,需要哪些依赖
首先回顾一下SpringBoot项目创建的过程
这里你可以勾选Create from archetype,然后选择下面的对应项目,但是这样创建的项目,有时候会产生一些不是必须的包,一般我个人是不选择的!!!
GroupID是项目组织唯一的标识符, 比如我的项目叫test001 那么GroupID应该是 com.lixiaoming.test001 域名.公司名.项目名
ArtifactID就是项目的唯一的标识符, 一般是 项目名-xxx 比如test001-model
下一步点击完成
这个时候项目是一个空项目,需要我们手动去配置启动类,pom中的依赖信息
1.首先需要一个parent包,这个是springboot的核心,在这个包下会有各种日常包的版本信息
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
</parent>
2.其次是一个spring-boot-starter,这是springBoot项目的启动类,缺少他,springboot项目无法启动
最后是一个spring-boot-starter-web,这个包就是web项目所必须的包
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
以上就是pom文件中最基础的依赖信息
然后就是配置启动类
在src/main/java 下创建对应项目的启动类
1.写@SpringBootApplication的注解,告诉sping这是启动类
2.在main方法中的SpringApplication.run(xx.args) xx需要和启动类的名字一致