Example of Spring IOC for complete java based configuration

  1. It’s very simple everything of xml configuration is replaced with annotations.

  2. Remove xml file.

  3. Replace xml with configuration java class.

  4. @configuration annotation

    1. This is just to inform where our configuration is placed like beans and properties file.

  5. @bean annotation

    1. Same as xml this will return objects

    2. See below samples:

@propertySource : To specify property file path in xml we used to use PropertyPlaceholderConfigurer class this is achieved by annotations.