tags:

views:

15

answers:

1

Hi all,

I am learning spring by reference documentation of 3.0

and i wanted to test the below functionality but these are not available..

  1. @PostConstruct
  2. context.registershutdownhook

P.S.: I am using jdk 5.0

when i type these in my eclipse,I am getting an error that these are not avaialble..

Below is my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.SpringExample</groupId>
    <artifactId>SpringExample</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>3.0.0.RELEASE</version>
            <scope>runtime</scope>
        </dependency>
    </dependencies>
</project>
A: 
  1. @javax.annotation.PostConstruct is not shipped with Spring, although Spring supports it if it finds it on the classpath. @PostConstruct can be found in Java6, but not in Java5. You can also find it in some EJB3 downloads.

  2. registerShutdownHook() is a method on ConfigurableApplicationContext, which is a subtype of ApplicationContext.

skaffman
javanoob
@javanerd: 1) Yes, 2) This isn't a POM problem, you're just looking at the wrong interface. You need to look at `ConfigurableApplicationContext`, not `ApplicationContext`.
skaffman
Thanks skaffman it worked..
javanoob