I am getting acquainted with Spring and I would like to go a little further than Hello World and do not understand how to build an application. For example, I created the bins, set them up. Created an entry point view:

public class Main { public static void main(String[] args) { ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class); .... 

And then begin to pull the first bin, etc.

 context.getBean(Bean1.class) 

Who will pull the rest and "unwind" the further logic of the program?

There are plenty of examples on the Internet, but all of them are not far from HelloWorld (with 2nd, 3 binami) or all of them are MVC.

It seems to me that in real applications, bins do not reach context.getBean (Bean1.class) in this form. Tell me "on the fingers" which is the standard template, or maybe somewhere there is an example ...

Thank.

  • It seems to you. Get out. - Sergey Gornostaev
  • @SergeyGornostaev, Doesn’t seem like @Autowired are using - Nick
  • @NickSavenia Well, write the answer with an example of how to correctly initialize the context and get the bean without context.getBean() in the console application. - Sergey Gornostaev

0