java - Spring - how to @Autowire a bean WITHOUT calling ClassPathXmlApplicationContext -


is possible autowire beans without calling:

applicationcontext context = new classpathxmlapplicationcontext("applicationcontext.xml"); 

if mean no-xml conifg try test

class t1 { }  class t2 {     @autowired     t1 t1; }  public class main {      public static void main(string[] args) throws exception {         annotationconfigapplicationcontext ctx = new annotationconfigapplicationcontext();         ctx.register(t1.class, t2.class);         ctx.refresh();         system.out.println(ctx.getbean(t2.class).t1);     } } 

it show t1 bean injected t2 bean


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -