4

In jdk9 @PostConstruct and @PreDestroy are in java.xml.ws.annotation which is deprecated and scheduled for removal.

I was wondering what to use when they are removed and also wouldn't be a problem due to the fact that a lot of frameworks and projects are using them?

riorio
  • 6,500
  • 7
  • 47
  • 100
dnny
  • 116
  • 1
  • 7
  • Hi, this is a good topic for a forum, it doesn't fit that well here – rick Sep 12 '18 at 08:45
  • 2
    I am pretty sure there is a duplicate existing for this. Ideally, move to use ` javax.annotation javax.annotation-api 1.3.2 ` – Naman Sep 12 '18 at 08:55
  • These annotations annotations are in - Module `java.xml.ws.annotation` - Package `javax.annotation` The module has been deprecated in [JEP-320][1], and the annotations have been published as standalone (Maven) artefact: [javax annotation API][2] javax.annotation javax.annotation-api 1.3.2 [1]: http://openjdk.java.net/jeps/320 [2]: https://search.maven.org/search?q=g:javax.annotation%20AND%20a:javax.annotation-api – Peter Walser Sep 12 '18 at 09:00

1 Answers1

1

I have found answer on this link

This example is just first example which should prepare your code for the latest modifications:

@Component
public class MyBean implements InitializingBean, DisposableBean {

    private void init() {
        //TODO: init code
    }


    private void shutdown() {
        //TODO: destroy code
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        init();
    }

    @Override
    public void destroy() throws Exception {
        shutdown();
    }
}
Adam Ostrožlík
  • 1,256
  • 1
  • 10
  • 16