[Java Spring] Controlling API Exposure & Override Endpoint Name
作者:互联网
@RestResource(exported = false): makes the endpoint no longer visible for public.
package com.example.ec.repo; import com.example.ec.domain.TourPackage; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.query.Param; import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.data.rest.core.annotation.RestResource; import java.util.Optional; // Rename the endpoint @RepositoryRestResource(collectionResourceRel = "packages", path = "packages") public interface TourPackageRepository extends CrudRepository<TourPackage, String> { /** * Find Tour Package by name. * * @param name name of the package * @return Optional of TourPackage */ Optional<TourPackage> findByName(@Param("name")String name); @Override @RestResource(exported = false) <S extends TourPackage> S save(S s); @Override @RestResource(exported = false) <S extends TourPackage> Iterable<S> saveAll(Iterable<S> iterable); @Override @RestResource(exported = false) void deleteById(String s); @Override @RestResource(exported = false) void delete(TourPackage tourPackage); @Override @RestResource(exported = false) void deleteAll(Iterable<? extends TourPackage> iterable); @Override @RestResource(exported = false) void deleteAll(); }
标签:Endpoint,false,Name,exported,import,Override,Java,RestResource,name 来源: https://www.cnblogs.com/Answer1215/p/14131347.html