mardi 3 mars 2020

I have an error with reflections java library, "Scanner SubTypesScanner was not configured"

I try to get classes that implements an interface in a given package, using reflections library.

I have the following code :

package TestClass;

import org.reflections.Reflections;

import org.reflections.scanners.SubTypesScanner;

import java.io.DataInputStream;
import java.io.InputStream;
import java.net.URL;
import java.util.*;

public class Checks {
    public static void main(String[] args) {
        Reflections reflections = new Reflections("TestReflection.src.TestClass");
        try{
            Set<Class<? extends CheckingClass>> classes = reflections.getSubTypesOf(CheckingClass.class);
        }catch(Exception e){
            System.out.println(e.toString());
        }
    }
}

It gives me this error : org.reflections.ReflectionsException: Scanner SubTypesScanner was not configured

It surprises me because i got the code from an example of how to use reflections library, so it should work.

Maybe i'm missing an important details.

Thanks





Aucun commentaire:

Enregistrer un commentaire