zoukankan      html  css  js  c++  java
  • Springboot~@EnableConfigurationProperties注解的作用

    • @Component || @Controller || @Service
    • @Configuration
    • @ConfigurationProperties
    • @EnableConfigurationProperties

    以上注解的关系梳理:
      @Component || @Controller || @Service 用来定义spring的bean。

    作用:
      @EnableConfigurationProperties的作用: 使@ConfigurationProperties 注解的类生效。

    正确的bean的属性配置加载

     

    错误bean的属性配置加载

    纠正: 错误bean的属性配置加载

    结果:
      如果一个配置类只配置@ConfigurationProperties注解,而没有使用@Component,那么在IOC容器中是获取不到properties 配置文件转化的bean。
    @EnableConfigurationProperties 是把指定类的属性又注入了一次。

    作者:donleo123
    本文如对您有帮助,还请多推荐下此文,如有错误欢迎指正,相互学习,共同进步。
  • 相关阅读:
    spring-boot快速搭建解析
    springmvc处理ajax跨域
    Spring-AOP解析
    springmvc注解
    springmvc源码分析
    Spring源码分析
    JAVA性能优化
    数据取舍
    命令行控制
    Junit常用操作
  • 原文地址:https://www.cnblogs.com/donleo123/p/14478867.html
Copyright © 2011-2022 走看看