zoukankan      html  css  js  c++  java
  • @propertySource @ImportResource @Bean

    @propertySource (value ={"classpath:......"}

    导入指定的配置的文件 ,让配置文件的内容生效。SpringBoot里面没有配置文件,

    我们自己编写的配置文件也不能自动识别,想让配置文件生效,加载进来@ImportResource标注在一个配置类上。

    @ImportResource(location={"classpath:xx.xml"})//导入配置文件

    @Configuration:指明当前配置类是一个配置类,就是用来替代之前的Spring配置文件的

    @Bean 将方法的返回值添加到容器中,容器中这个组件默认的ID就是方法名

    @Bean是一个方法级别上的注解,主要用在@Configuration注解的类里,也可以用在@Component注解的类里。添加的bean的id为方法名

     SpringBoot 推荐给容器中添加组件的方式

    1.配置类========Spring配置文件//配置类在类的上面写上@Configuration

    2 使用@Bean给容器中添加组件

  • 相关阅读:
    你人生中的那口井挖了没有?
    Stream接口
    console (控制台)
    assert.fail()
    assert.strictEqual()
    assert.equal()
    assert.ifError()
    assert.ok()
    nodejs assert 模块
    闭包
  • 原文地址:https://www.cnblogs.com/shitulaoma/p/12464967.html
Copyright © 2011-2022 走看看