弹簧注入在用户创建的实例中工作?

Kri*_*man 0 java spring inversion-of-control

我正在使用Spring,当我使用new运算符创建实例时,我将注入的实例作为null,我可以调整场景.

例如,让A类和B类注入Main类


      class Main
         {
       @autowired
      A a;
        @autowired
       B b;

    //getter and setter
   }

class MainExecute
{
 public static void main()
 {
   // loading the spring config xml 
 Main main = new  Main();
 A a=main.getA();
  // whether a will get the instance  ( I'm getting a as null) 

 }
Run Code Online (Sandbox Code Playgroud)

这种情况可能是什么原因请指导我

提前致谢.