Reputation: 190
I am developing spring mvc web application. I want to inject a bean class inside controller or service class but I don't want to use any type of annotation.
Upvotes: 1
Views: 516
Reputation: 4838
Define you bean in your appContext.xml or your bean config file
<bean id="mybean" class="MyClass"></bean>
And call your bean inside your controller using ApplicationContext interface :
ApplicationContext context = new FileSystemXmlApplicationContext("appContext.xml");
MyClass mybean= applicationContext.getBean("mybean");
Upvotes: 2