https://grokonez.com/spring-framework/difference-between-annotation-config-and-component-scan

Difference between annotation-config and component-scan

annotation-config and component-scan are important basic concepts of Spring Core.
This tutorial helps you understand how to use them and difference between them.

I. Overview

<context:annotation-config> activates all annotations in beans which are already registered in the application context. Those beans could be defined with XML or by package scanning.

<context:component-scan> not only does everything that annotation-config does, but also registers the java classes as a bean which are annotated with @Component, @Service ,@Repository…

II. Usage

Now begin with hierarchy that we want to create in our application: -|Bean Name -|Bean Address -|Bean Customer ------|injected Bean Name ------|injected Bean Address

1. Full Beans in XML

The java class for Bean are:

public class Name{ //... }
public class Address{ //... }

public class Customer {
private Name name;
private Address address;

public Customer() //...
public void setName(Name name) //setter injection...
public void setAddress(Address address) //setter injection...

}

More at:

https://grokonez.com/spring-framework/difference-between-annotation-config-and-component-scan

Difference between annotation-config and component-scan

#spring

Difference between annotation-config and component-scan » grokonez
1.05 GEEK