2

Lets say i have a class Foo defined by @Component annotation:

@Component
public class Foo{
}

Then in configuration class

@Configuration
@ComponentScan
public class Configuration{

   @Bean
   public Foo foo(){
      return new Foo();
   }

I've ran it succeed but can some one explain the details of the concept here ? Thanks!

meobeo173
  • 617
  • 1
  • 7
  • 20
  • 2
    http://docs.spring.io/spring/docs/current/spring-framework-reference/html/beans.html – Stefan Jun 07 '16 at 06:33
  • Are you asking about the difference of `@Component`, `@Service`, `@Repository` and `@Controler`, or is your question about the componentscan-autowiring process? – Ralph Jun 07 '16 at 06:39
  • some-what similar question: http://stackoverflow.com/questions/10604298/spring-component-versus-bean – pbajpai Jun 07 '16 at 06:40
  • 1
    @Ralph in my knowledge , Bean and Component are different but quite do the same job, and i wonder why there weren't any conflicts? – meobeo173 Jun 07 '16 at 06:46
  • So your question is, why there is no conflict between to two almost equal nammed and typed beans? – Ralph Jun 07 '16 at 08:36

0 Answers0