Q:在整合其他框架时(如mybatis),springboot 的application.properties 怎样配置或者引入其他框架的配置文件。
Q:application.properties里面常用的配置属性有哪些?
springboot整合mybatis
springboot没有提供mybatis集成的官方支持,但是mybatis社区自己为mybatis搞了个starter(mybatis-spring-boot-starter)。这就是为什么application.properties里面没有关于mybatis的配置项,而我们可以在application.properties里面写
mybatis.config = mybatis config file name
mybatis.mapperLocations = mappers file locations
mybatis.typeAliasesPackage = domain object's package
mybatis.typeHandlersPackage = handler's package
mybatis.check-config-location = check the mybatis configuration exists
mybatis.executorType = mode of execution. Default is SIMPLE
的原因。
SpringBoot doesn’t provide official support for MyBatis integration, but the MyBatis community built a SpringBoot starter for MyBatis.
springboot可以配置开发(dev)和生成(product)环境的配置文件如(application-dev.properties\application-prod.properties)。然后启动springboot的jar包时,使用
指定配置文件就行。默认使用的是application.properties。
application.properties里面常用的配置属性有哪些
Spring Boot - Application Properties
总结
所以,springboot整合其他框架的关键在于,是否提供相应的xx-spring-boot-starter。(xx就可以从application.xml里面读取配置项了)
参考文献
Spring Boot - Application Properties
Appendix A. Common application properties