简体   繁体   中英

Classpath Scanning in Spring Boot Jar Not Working

I have a custom annotation:

@Target(value=ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Pipeline  {
  String id ();
  String name ();
  boolean visible () default true;
  String role () default "USER";
}

Which I use on interfaces within a Spring Boot App with nested jars:

@Pipeline(id="my-pipeline", name="My Pipeline")
public interface Echo {
  ...
}

My project structure:

parent-boot-project
   |
   --- plugin1.jar 
   --- plugin2.jar <--- interfaces are here
   --- ...

Next, I use lukehutch's fast-classpath-scanner to scan for them:

new FastClasspathScanner(BASE_PACKAGE)
    .matchClassesWithAnnotation(PIPELINE_ANNOTATION, aProcessor)
    .verbose()
    .scan();

Works great on my IDE (eclipse) but not when I build the jar. Tried messing around with the classpath but to no avail. Anyone ran into something like that?

FastClasspathScanner已重命名为ClassGraph,现在具有完整的Spring Boot扫描支持。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM