Now based on this link http://www.mkyong.com/spring/spring-postconstruct-and-predestroy-example/ i done but in that example they using xml files so please help me to do using spring annotation or other way thanks in advance...
Asked
Active
Viewed 619 times
1 Answers
1
It doesn't matter how you create your bean (XML, annotation, @Configuration class). As long
as you have the <context:annotation-config />
it should work.
If you use @Configuration
class you should add this annotation as well to the base configuration class @EnableWebMvc
They even mention adding it in the tutorial you referred to.

Avi
- 21,182
- 26
- 82
- 121
-
yeah you are right Avi. But for standalone java project with spring means is there any way to handle it??? – Sujeeth Damodharan Dec 03 '14 at 10:34
-
1@SujeethDamodharan - You have to have an initial spring context in any case. Anyway, I edited my answer and added the right annotation to use when configuring with configuration class and not with XML. But still in a standalone app you need to programatically load the context somehow in order for the annotations to work. – Avi Dec 03 '14 at 11:57
-
Thanks a lot Avi. i found this AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext ( RootConfig.class ); to enable the annotation . In Root configuration i defined all required bean its working like a charm for standalone java app with Spring :) :) #Thanks – Sujeeth Damodharan Dec 03 '14 at 12:47