クラスに注釈を付ける場合は、その注釈の定義をクラスを使用するために実行時クラスパスに含める必要がありますか?例えば、私はクラスパスにComponent.classを持たずにプログラムランタイムクラスパスにアノテーションクラスファイルが必要ですか?
@Component
public class Test {
public static void main(String[] args) {
System.out.println("It worked!");
}
}
を実行することができ、注釈
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Retention;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Component {}
与えられましたか? (私のテストではできましたが、仕様で定義されたこの動作ですか?)
conflicting claimsライブラリにアノテーションを使用すると、そのライブラリに依存関係が作成されるかどうかがわかります。
関連リンク:http://mail.openjdk.java.net/pipermail/type-annotations-dev/2011-November/000079.html、https://bugs.eclipse.org/bugs /show_bug.cgi?id=366063(将来のクイックリファレンス用) – Jayan
可能なdup:http://stackoverflow.com/questions/3567413/why-doesnt-a-missing-annotation-cause-a-classnotfoundexception-at-runtime –
ありがとうマット、まさに私が探していたものです。 – meriton