Eager instantiation is Spring’s default behavior for singleton beans: Spring creates them while initializing the context, even if the application does not request them. section 5.1.2
A bean created before it is requested
A CommentService constructor prints a message when called. Start the Spring context without retrieving CommentService, and the message still appears: Spring created the bean during initialization. section 5.1.2
Listing 5.8 Adding a log line to the bean’s constructor
@Service
public class CommentService {
public CommentService() {
System.out.println("CommentService instance created!");
}
}The constructor log makes bean creation observable. section 5.1.2
