What is the clearest way to deprecate a package in Java?

前端 未结 6 587
孤独总比滥情好
孤独总比滥情好 2020-12-15 03:19

I\'m working on a new codebase and migrating the system to a new framework.

There are a number of packages that I would like to deprecate, just to make it very clear

6条回答
  •  星月不相逢
    2020-12-15 03:27

    I had to do this recently and used the package-info.java file to deprecate the package.

    http://www.intertech.com/Blog/whats-package-info-java-for/

    Add a package-info.java file to your package with only the package declaration:

    /**
     * @deprecated As of release 2.0, replaced by {@link com.acme.new.package}
     */
    @Deprecated
    package com.acme.old.package;
    

    In Eclipse, all places where the user imports a class from this package will be underlined with a deprecation warning.

提交回复
热议问题