The main method is not the proper place to get beans from the application context. It's only there to set up the application context.
When a request hits your application, Spring will create controllers and inject beans automatically. You just need to annotate your classes with annotations that indicate that those instances are also managed by Spring. Examples include @Component, @Controller, etc.
If what you want to do is test beans, use a test framework. Such as Junit.
JUnit is an external testing system. It does not require modifications to application code to use - and modifications can alter the reliability and security of the application, so it's better to avoid them. You don't need a Main() method, because the Main() for JUnit testing is within JUnit itself.
If you're using a build system such as Maven, the build system can run unit testing as part of the build process and in many cases even generate reports. Many of the "big ticket" open-source projects are built and tested by Maven.
I'm going to be a "small government" candidate. I'll be the government. Just me. No one else.
Use another implementation of ApplicationContext - AnnotationConfigApplicationContext. So write just like that:
@ComponentScan means IoC container(your context) finds and creates all the beans itself. So if you annotate your classes as @Component, then your configuration class scans all these annotated classes and creates beans.