Spring @Autowire on method

user1409534

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?

Do Nhu Vy

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related