Q:

My class fileds are getting initialized may be because I have a @bean for the same class but in a different .java file

I am new to spring and annotations.
I started the application in debug mode and I found that by the time my code reaches init() method of Actuator below values got assigned to actVar1 and actVar2.
actVar1 has "abc" value
actVar2 has  "xyz" value
Note: My application is not yet started completely . I am just trying with debug point in init() method for a different purpose and I observed above thing.
My question is why those variables have assigned those values.
//Actuator.java 
@Component
public class Actuator {
private String actVar1;
private String actVar2;
//.. some code here
@PostConstruct
public void init(){
//my debug point is here 
//some code .....
}
//.. some code here

}
//Beancreator.java
@Component
public class BeanCreator {
//.. some code here
private String first="abc";
private field2 second ="xyz";
//.. some code here

@Bean 
public Actuator actuator() { 
Actuator actuator = new Actuator(); 
actuator.setActVar1(first); 
actuator.setActVar2(second); 
return actuatorPoller; 
} 
//.. some code here
}

When I change the method name under @Bean to different one ,those values are not getting assigned .

A:

My question is why those variables have assigned those values ?

First, after Spring creates a bean, it will call that bean 's @PostConstruct method.
Second , Spring will create a bean for the following cases: 

If a class is annotated by @Component or its stereotype annotation such as @Repository, @Service, and @Controller etc , and auto-scanning feature is enable for the package containing that class , it will create a bean for it.
If a method on @Configuration /@Component class is annotated with @Bean , Spring will call that method to create a bean. 

So your example creates 2 beans in the type of Actuator. A is due to @Component on Actuator class while B is due to @Bean method on BeanCreator.actuator().That 's why you see init() executes two times as there are two Actuator beans. For A , its init() is executed with NULL. For B, its init() is executed with "abc" and "xyz" simply because you set it in the @Bean method that creates it.

