1.发现每个新建的springboot项目都有一个父依赖

	 <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.0.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
	</parent>

2.每个springboot-web项目都有依赖

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

3.总结

1.首先springboot的核心就是starter模块核心依赖和autoconfiguration自动配置
		starter:每个spring框架都有与之对应的starter,如springmvc有spring-boot-starter-web
					spring-boot-starter-web内置web容器tomcate等
		autoconfiguration:自动化配置为springboot项目简化了繁琐的配置文件;核心就是通过@SpringBootApplication继承了
					@SpringBootConfiguration和@EnableAutoConfiguration和@ComponentScan这三个注解;而配置文件
					application.yml和@configuration定义的类的配置能够生效,就是靠autoconfiguration;可以通过
					spring-boot-autoconfigration-1.2.*.RELEASE.jar里面的spring-configuration-metadata.json看到所有当前		 
					starter(框架)下面所有定义的配置属性。
2.spring-boot-starter-parent是一个springboot项目的父工程,它定义了很多当前项目的规范
		1.定义了 Java 编译版本为 1.8 。
		2.使用 UTF-8 格式编码。
		3.继承自 spring-boot-dependencies,这个里边定义了依赖的版本,也正是因为继承了这个依赖,所以我们在写依赖时才		 
			不需要写版本号。
		4.执行打包操作的配置。
		5.自动化的资源过滤。
		6.自动化的插件配置。
		7.针对 application.properties 和 application.yml 的资源过滤,包括通过 profile 定义的不同环境的配置文件,
			例如 application-dev.properties 和 application-dev.yml。
3.所以一般的maven父pom工程都继承spring-boot-dependencies;如
		<dependencyManagement>
		    <dependencies>
		        <dependency>
		            <groupId>org.springframework.boot</groupId>
		            <artifactId>spring-boot-dependencies</artifactId>
		            <version>2.1.4.RELEASE</version>
		            <type>pom</type>
		            <scope>import</scope>
		        </dependency>
		    </dependencies>
		</dependencyManagement>
		这样写之后,依赖的版本号问题虽然解决了,但是关于打包的插件、编译的 JDK 版本、文件的编码格式等等
		这些配置,在没有 parent 的时候,这些统统要自己去配置。
GitHub 加速计划 / sp / spring-boot
40
9
下载
spring-projects/spring-boot: 是一个用于简化Spring应用开发的框架。适合用于需要快速开发企业级Java应用的项目。特点是可以提供自动配置、独立运行和内置的Tomcat服务器,简化Spring应用的构建和部署。
最近提交(Master分支:3 个月前 )
927b2eef Closes gh-48637 21 小时前
d555a112 Closes gh-48636 21 小时前
Logo

AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。

更多推荐