I am using Spring MVC for my web application. My beans are written in "spring-servlet.xml" file

Now I have a class MyClass and i want to access this class using spring bean

In the spring-servlet.xml i have written following

<bean id="myClass" class="com.lynas.MyClass" />

Now i need to access this using ApplicationContext

ApplicationContext context = ??

So that I can do

MyClass myClass = (MyClass) context.getBean("myClass");

How to do this??



@Autowired
private ApplicationContext appContext;



source - http://stackoverflow.com/questions/21827548/spring-get-current-applicationcontext





'Framework & Platform > Spring' 카테고리의 다른 글

spring - ServletContext  (0) 2015.07.16
spring - headers="Accept=*/*"  (0) 2014.12.26
spring - restTemplate example  (0) 2014.09.12
spring - @Autowired @Resource @Qualifier  (0) 2014.09.05
spring data - jpa insert  (0) 2014.08.24
Posted by linuxism
,