Code Monkey home page Code Monkey logo

spring-annotation's Introduction

spring-annotation

demo-01:

  1. MainConfig01
    1. @Configuration 注入配置类
    2. @Bean 注入组件
    3. @ComponentScan 扫描指定包注入以下注解指定的类
      • @Controller
      • @Service
      • @Repository
      • @Component
  2. MainConfig02
    1. @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) 设置单例或多例 默认单例
    2. @Lazy 懒加载,仅针对单例
  3. MainConfig03
    1. @Conditional(MyCondition.class)@Bean注解一起使用 MyCondition继承Condition重写matches方法 true-注入 false-不注入
    2. @Import(ImportClassOne.class)@Configuration一起使用导入指定类,名称为全类名
    3. @Import(MyImportSelector.class)MyImportSelector实现了ImportSelector接口,重写selectImports方法,返回组件全类名数组
    4. @Import(MyImportBeanDefinitionRegistrarClassOne.class)MyImportBeanDefinitionRegistrarClassOne实现了ImportBeanDefinitionRegistrar接口, 重写了registerBeanDefinitions方法,在方法里手工registerBeanDefinition
    5. FactoryBean<> 注入一个实现了 FactoryBean 接口的 bean,获取该 bean 时得到由 getObject 返回的 bean, 名称前置&可以获得该FactoryBean本身

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.