@Component
@Slf4j
public class SpringDataRestCustomization extends RepositoryRestConfigurerAdapter {
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
listMatchingClasses(Entity.class).forEach(entity -> config.exposeIdsFor(entity));
}
public List<Class> listMatchingClasses(Class annotationClass) {
List<Class> classes = new LinkedList<Class>();
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(true);
scanner.addIncludeFilter(new AnnotationTypeFilter(annotationClass));
for (BeanDefinition bd : scanner.findCandidateComponents(Project.class.getPackage().getName())) {
try {
classes.add(Class.forName(bd.getBeanClassName()));
} catch (ClassNotFoundException e) {
log.error("listMatchingClasses problem", e);
}
}
return classes;
}
}
miércoles, 15 de marzo de 2017
Spring data rest, HATEOAS exposeIds
Para que las rests HATEOAS muestren los campos id de cada elemento:
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario