Autowired and config method in Spring Security

Autowired means an instance bean in application context will be injected where the @Autowired is used.

For example

 
@Autowired
private UserService userService;
 

An instance of UserService will be inject so yo don't have to new it.

If you use @Autowired on a method, it makes the method a config method which means you can configure the system in this method, and this is the only thing you do. Its like a plugin, a callback, it gives you a chance to plug the system.

The config method will be invoked by container, the parameters are passed in by container, the only thing you do is configuration, usually some key value pairs. The system know how to use these configurations.

The method name is not important, because Spring locate the method by their type signature. The best example is the security configurer that extends WebSecurityConfigurerAdapter.