0 课程地址
https://coding.imooc.com/lesson/380.html#mid=28269
1 主要内容
1.1 pom.xml的基本结构
a parent标签加入springboot,标识springboot项目(引入springboot依赖)
b 添加maven坐标,标识maven项目
c dependency标签引入其它依赖
d build引入其他插件
2 个人收获
2.1 pom中右键没有maven选项后如何处理
原因是右键pom.xml,-->maven-->remove projects
解决方法,右键add as mavenproject
3 课程内容
3.1 demo
a 新建maven项目
b 修改pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <!-- 1 引入springboot --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.4.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <!-- 2 maven 坐标信息--> <groupId>com.imooc.springboot.study</groupId> <artifactId>imooc_springboot_study</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <!-- 项目名字介绍--> <name>springboot-study</name> <description>Study project for Spring Boot</description> <!-- 3 引入相关依赖--> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.31</version> </dependency> <!-- 专门用于数据绑定的依赖 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> </dependencies> <!-- 4 引入相关插件--> <build> <finalName>imooc-springboot-study</finalName> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
c 编写顶类
package com.imooc.springboot.application; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * SpringBootApplication * * @author 魏豆豆 * @date 2021/1/13 */ @SpringBootApplication public class SpringBootStudyApplication { public static void main(String [] args){ SpringApplication.run(SpringBootStudyApplication.class,args); } }
d 运行main函数