今天想要导入thymeleaf的依赖,但是又不想从其他博复制粘贴,于是去spring官方文档找一找
在idea新建的springbootweb项目中,有一个HELP.md文件,里面包含spring web的官方文档地址
打开它 找到链接
https://docs.spring.io/spring-boot/docs/2.2.0.RELEASE/reference/htmlsingle/#boot-features-developing-web-applications
打开链接
选择第序号3.Using Spring Boot,再选择starter找到启动器配置
找到thymeleaf启动器依赖选项
点击蓝色的Pom会直接跳转到thymeleaf的github地址
找到maven依赖
1 <dependency> 2 <groupId>org.thymeleaf</groupId> 3 <artifactId>thymeleaf-spring5</artifactId> 4 </dependency> 5 <dependency> 6 <groupId>org.thymeleaf.extras</groupId> 7 <artifactId>thymeleaf-extras-java8time</artifactId> 8 </dependency>
添加进pom.xml 多了关于thymeleaf的jar包
把依赖换成springboot的启动器
发现导入的jar包毫无变化
原因:Spring Boot会将一些功能场景抽取出来,做成一个个的启动器(starters),只需要在项目里面引入这些starter,相关场景的所有依赖都会导入进来
查找这些启动器就在https://docs.spring.io/spring-boot/docs/2.2.0.RELEASE/reference/htmlsingle/#using-boot-starter
或者springboot的配置文件spring.factories里面查找