import com.beaninject.Inject; public class MyBean { @Inject private AnotherBean anotherBean; } <beans> <bean class="com.example.AnotherBean" id="anotherBean"/> <bean class="com.example.MyBean" id="myBean"/> </beans> import com.beaninject.BeanInject; public class MyApp { public static void main(String[] args) { BeanInject.init("bean-inject.xml"); } } import com.beaninject.Inject; public class AnotherBean { public void doSomething() { } } public class MyBean { @Inject private AnotherBean anotherBean; public void execute() { anotherBean.doSomething(); } } public class MyApp { public static void main(String[] args) { BeanInject.init("bean-inject.xml"); MyBean myBean = BeanInject.getBean(MyBean.class); myBean.execute(); } }