private Set<Class<?>> scanForEntities(final String basePackage) {
        if (StringUtils.isBlank(basePackage)) {
            return new HashSet<>();
        }

        val initialEntitySet = new HashSet<Class<?>>();
        if (StringUtils.isNotBlank(basePackage)) {
            val componentProvider = new ClassPathScanningCandidateComponentProvider(false);
            componentProvider.addIncludeFilter(new AnnotationTypeFilter(Document.class));
            componentProvider.addIncludeFilter(new AnnotationTypeFilter(Persistent.class));
            initialEntitySet.addAll(findAndLoadComponents(basePackage, componentProvider));
        }

        return initialEntitySet;
    }
Build mongo template.

@param mongoClient the mongo client
@param mongo       the mongo
@return the cas mongo operations
support/cas-server-support-mongo-core/src/main/java/org/apereo/cas/mongo/MongoDbConnectionFactory.java