常用类属于哪些jar包


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接口

原文地址:http://www.cnblogs.com/panxuejun/p/6711118.html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值