從上面可以看出,pom.xml文件中會引入一些jar包,其中除了引入spring-boot-starter,之外重點看一下:mybatis-spring-boot-autoconfigure 。
我們找到mybatis-spring-boot-autoconfigure.jar文件,打開這個文件 。

文章插圖
里面包含如下文件:
- 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 系統(tǒng)自動生成的IDE提示功能
- ConfigurationCustomizer 自定義Configuration回調(diào)接口
- MybatisAutoConfiguration mybatis配置類
- MybatisProperties mybatis屬性類
- SpringBootVFS 掃描嵌套的jar包中的類
spring-configuration-metadata.json和additional-spring-configuration-metadata.json的功能差不多,我們在applicationContext.properties文件中輸入spring時,會自動出現(xiàn)下面的配置信息可供選擇,就是這個功能了 。
文章插圖
來自靈魂的一問:這兩個文件有什么區(qū)別?
答:如果pom.xml中引入了
spring-boot-configuration-processor包,則會自動生成spring-configuration-metadata.json 。如果需要手動修改里面的
元數(shù)據(jù),則可以在additional-spring-configuration-metadata.json中編輯,最終兩個文件中的元數(shù)據(jù)會合并到一起 。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()]);}}
經(jīng)驗總結(jié)擴展閱讀
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 比較高級的土味情話
- 大麥小麥和燕麥的區(qū)別
- 2023年2月15日是請佛吉日嗎 2023年2月15日是請佛的黃道吉日嗎
- 鎢做燈絲的原因
- 雄蠶蛾泡酒方法
- 微信運動關(guān)注的人是什么意思
- 通大便的食物與水果
- 經(jīng)典力學(xué)的奠基人是誰
- 中度貧血會頭暈嗎
- 養(yǎng)生堂維生素c的功效
