Java annotations not being found in JAR file using org.reflections -
i'm using org.reflections library detect classes annotated in project. when run project eclipse, annotated classes found.
however, when project packaged jar file , run, no annotated classes found.
here example code:
@testannotation public class app { public static void main (string[] args) { reflections reflections = new reflections("com.package"); set<class<?>> annotated = reflections.gettypesannotatedwith(testannotation.class); (class c : annotated) { system.out.println ("found annotated class " + c.getname()); } } }
when run code in jar file there no output. doing wrong?
thanks
pay attention
reflections reflections = new reflections("com.package");
there try explore annotated classes located in package package nested in com package. package
java keyword. can not used name of package. after moved app
, testannotation
com package works fine.
but possible case bad. may tool or person created package has package name (for example, used cyrillic а
instead of latin a
, both looking same in editor, totally different java). when letters mixed looks fine doesn't work. try create new valid root package , move classes it.
Comments
Post a Comment