从上面可以看出,pom.xml文件中会引入一些jar包,其中除了引入spring-boot-starter
,之外重点看一下:mybatis-spring-boot-autoconfigure
。
我们找到mybatis-spring-boot-autoconfigure.jar
文件,打开这个文件 。
![SpringBoot的starter到底是什么?](http://shimg.jingyanzongjie.com/230724/23524U217-2.png)
文章插图
里面包含如下文件:
- pom.properties配置maven所需的项目version、groupId和artifactId
- pom.xml配置所依赖的jar包
- additional-spring-configuration-metadata.json手动添加IDE提示功能
- MANIFEST.MF 这个文件描述了该Jar文件的很多信息
- spring.factories SPI会读取的文件
- spring-configuration-metadata.json 系统自动生成的IDE提示功能
- ConfigurationCustomizer 自定义Configuration回调接口
- MybatisAutoConfiguration mybatis配置类
- MybatisProperties mybatis属性类
- SpringBootVFS 扫描嵌套的jar包中的类
spring-configuration-metadata.json
和additional-spring-configuration-metadata.json
的功能差不多,我们在applicationContext.properties
文件中输入spring时,会自动出现下面的配置信息可供选择,就是这个功能了 。![SpringBoot的starter到底是什么?](http://shimg.jingyanzongjie.com/230724/23524Q534-3.png)
文章插图
来自灵魂的一问:这两个文件有什么区别?
答:如果pom.xml中引入了
spring-boot-configuration-processor
包,则会自动生成spring-configuration-metadata.json
。如果需要手动修改里面的
元数据
,则可以在additional-spring-configuration-metadata.json
中编辑,最终两个文件中的元数据会合并到一起 。MybatisProperties
类是属性实体类:@ConfigurationProperties(prefix = MybatisProperties.MYBATIS_PREFIX)public class MybatisProperties {public static final String MYBATIS_PREFIX = "mybatis";private String configLocation;private String[] mapperLocations;private String typeAliasesPackage;private String typeHandlersPackage;private boolean checkConfigLocation = false;private ExecutorType executorType;private Properties configurationProperties;@NestedConfigurationPropertyprivate Configuration configuration;public String getConfigLocation() {return this.configLocation;}public void setConfigLocation(String configLocation) {this.configLocation = configLocation;}@Deprecatedpublic String getConfig() {return this.configLocation;}@Deprecatedpublic void setConfig(String config) {this.configLocation = config;}public String[] getMapperLocations() {return this.mapperLocations;}public void setMapperLocations(String[] mapperLocations) {this.mapperLocations = mapperLocations;}public String getTypeHandlersPackage() {return this.typeHandlersPackage;}public void setTypeHandlersPackage(String typeHandlersPackage) {this.typeHandlersPackage = typeHandlersPackage;}public String getTypeAliasesPackage() {return this.typeAliasesPackage;}public void setTypeAliasesPackage(String typeAliasesPackage) {this.typeAliasesPackage = typeAliasesPackage;}public boolean isCheckConfigLocation() {return this.checkConfigLocation;}public void setCheckConfigLocation(boolean checkConfigLocation) {this.checkConfigLocation = checkConfigLocation;}public ExecutorType getExecutorType() {return this.executorType;}public void setExecutorType(ExecutorType executorType) {this.executorType = executorType;}public Properties getConfigurationProperties() {return configurationProperties;}public void setConfigurationProperties(Properties configurationProperties) {this.configurationProperties = configurationProperties;}public Configuration getConfiguration() {return configuration;}public void setConfiguration(Configuration configuration) {this.configuration = configuration;}public Resource[] resolveMapperLocations() {ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();List<Resource> resources = new ArrayList<Resource>();if (this.mapperLocations != null) {for (String mapperLocation : this.mapperLocations) {try {Resource[] mappers = resourceResolver.getResources(mapperLocation);resources.addAll(Arrays.asList(mappers));} catch (IOException e) {// ignore}}}return resources.toArray(new Resource[resources.size()]);}}
经验总结扩展阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 比较高级的土味情话
- 大麦小麦和燕麦的区别
- 2023年2月15日是请佛吉日吗 2023年2月15日是请佛的黄道吉日吗
- 钨做灯丝的原因
- 雄蚕蛾泡酒方法
- 微信运动关注的人是什么意思
- 通大便的食物与水果
- 经典力学的奠基人是谁
- 中度贫血会头晕吗
- 养生堂维生素c的功效