- Spring-boot 如何简化项目配置?
1.1. 通过多层次maven依赖简化pom.xml配置, 依赖关系如下:
spring-boot-starter-web
--spring-boot-starter
----spring-boot
------spring-context
--------spring-aop
--------spring-beans
----------spring-core
--------spring-expression
--spring-boot-autoconfigure
------spring-boot
----spring-boot-starter-logging
------logback-classsic
----spring-core
----snakeyaml
--spring-boot-starter-tomcat
--hibernate-validator
--jackson-databind
----jackson-annotations
----jackson-core
--spring-web
----spring-aop
------spring-beans
--------spring-core
--spring-webmvc
1.2 通过注解简化spring.xml配置
@SpringBootApplication(scanBasePackages = {"com.xinxin"}, exclude = {})
相当于@Configuration,@EnableAutoConfiguration,@ComponentScan
@ServletComponentScan(basePackages = {"com.xinxin"})
扫描basePackages中的@WebServlet、@WebFilter、@WebListener
@MapperScan("com.xinxin.dao")
扫描mybatis框架中的dao接口, 生成dao代理bean
@EnableTransactionManagement
开启注解事务管理,等同于xml配置方式的 <tx:annotation-driven />