0

I've seen in many example the use of @Autowire in spring on a method. For example in configuration file:

@Component
public class SomeConfigFile{

@Autowire
public void someMethod(SomeBeanInstance someBean){
//bla bla
}

I guess someBean in my example above injected to the method by Spring but when does this method is called? and how calls it?

user1409534
  • 1,990
  • 2
  • 24
  • 29

1 Answers1

1

Marks a constructor, field, setter method, or config method as to be autowired by Spring's dependency injection facilities. This is an alternative to the JSR-330 Inject annotation, adding required-vs-optional semantics.

see https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/beans/factory/annotation/Autowired.html

Jens
  • 63,364
  • 15
  • 92
  • 104
James Graham
  • 39,063
  • 41
  • 167
  • 242