1.@requestmapping注解,屬於org.springframework.web.bind.annotation包下。org.springframework.web jar包。
2.@RestController注解,也屬於org.springframework.web.bind.annotation包下,org.springframework.web jar包。
都是spring mvc,也就是spring web jar包下
3.@ComponentScan(basePackages = "com.pingan.property.icore.pap.*")注解,包掃面注解,屬於spring下的jar包,context上下文中嘛,負責spring的ioc注入。
--->org.springframework.context.annotation;org.springframework.context jar包
4.@SpringBootApplication 屬於org.springframework.boot.autoconfigure包下。org.springframework.boot jar包下。
5.@MapperScan(basePackages = "com.pingan.property.icore.pap.**.dao")注解,mapper當然屬於mybatis了,所以屬於mybatis的jar包下。
屬於org.mybatis.spring.annotation;org.mybatis.spring jar包下。mybatis對接spring的jar包叫做org.mybatis.spring jar包
@SpringBootApplication @ComponentScan(basePackages = "com.pingan.property.icore.pap.*") @MapperScan(basePackages = "com.pingan.property.icore.pap.**.dao") public class DemoApplication implements EnvironmentAware { private RelaxedPropertyResolver propertyResolver; @Override public void setEnvironment(Environment env) { this.propertyResolver = new RelaxedPropertyResolver(env, "spring.datasource."); } @Bean(destroyMethod = "close", initMethod = "init") public DataSource dataSource() { DruidDataSource dataSource = new DruidDataSource(); dataSource.setUrl(propertyResolver.getProperty("url")); dataSource.setDriverClassName(propertyResolver.getProperty("driverClassName")); dataSource.setDefaultAutoCommit(Boolean.parseBoolean(propertyResolver.getProperty("defaultAutoCommit"))); return dataSource; } public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } }
6.@Bean注解,屬於org.springframework.context.annotation下,都是用來項目啟動時向ioc容器中注入bean的注解。
@Bean(destroyMethod = "close", initMethod = "init") public DataSource dataSource() { DruidDataSource dataSource = new DruidDataSource(); dataSource.setUrl(propertyResolver.getProperty("url")); dataSource.setDriverClassName(propertyResolver.getProperty("driverClassName")); dataSource.setDefaultAutoCommit(Boolean.parseBoolean(propertyResolver.getProperty("defaultAutoCommit"))); return dataSource; }
7.@@Configuration org.springframework.context.annotation;
6.EnvironmentAware 接口,屬於org.springframework.context包下
7.RelaxedPropertyResolver類,屬於org.springframework.boot.bind包下。
public class RelaxedPropertyResolver implements PropertyResolver,實現了PropertyResolver接口