diff --git a/rest/pom.xml b/rest/pom.xml index d361a147..5aef409a 100644 --- a/rest/pom.xml +++ b/rest/pom.xml @@ -15,7 +15,7 @@ Sample projects for Spring Data REST - + starbucks projections security diff --git a/rest/starbucks/pom.xml b/rest/starbucks/pom.xml index 122cbb8c..9eabe98e 100644 --- a/rest/starbucks/pom.xml +++ b/rest/starbucks/pom.xml @@ -22,6 +22,7 @@ de.flapdoodle.embed de.flapdoodle.embed.mongo + 4.16.2 runtime @@ -69,14 +70,14 @@ org.webjars jquery - 2.1.3 + 3.7.1 runtime org.webjars bootstrap - 3.3.4 + 5.3.3 runtime diff --git a/rest/starbucks/src/main/java/example/springdata/rest/stores/StoreInitializer.java b/rest/starbucks/src/main/java/example/springdata/rest/stores/StoreInitializer.java index 2f27b74e..85f34688 100644 --- a/rest/starbucks/src/main/java/example/springdata/rest/stores/StoreInitializer.java +++ b/rest/starbucks/src/main/java/example/springdata/rest/stores/StoreInitializer.java @@ -28,7 +28,6 @@ import org.springframework.batch.item.file.FlatFileItemReader; import org.springframework.batch.item.file.mapping.DefaultLineMapper; import org.springframework.batch.item.file.separator.DefaultRecordSeparatorPolicy; import org.springframework.batch.item.file.transform.DelimitedLineTokenizer; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ClassPathResource; import org.springframework.data.geo.Point; import org.springframework.data.mongodb.core.MongoOperations; @@ -45,7 +44,6 @@ import org.springframework.stereotype.Component; @Component public class StoreInitializer { - @Autowired public StoreInitializer(StoreRepository repository, MongoOperations operations) throws Exception { if (repository.count() != 0) { @@ -64,8 +62,8 @@ public class StoreInitializer { } /** - * Reads a file {@code starbucks.csv} from the class path and parses it into {@link Store} instances about to - * be persisted. + * Reads a file {@code starbucks.csv} from the class path and parses it into {@link Store} instances about to be + * persisted. * * @return * @throws Exception diff --git a/rest/starbucks/src/main/java/example/springdata/rest/stores/StoreRepository.java b/rest/starbucks/src/main/java/example/springdata/rest/stores/StoreRepository.java index 366bc363..1a67b3f9 100644 --- a/rest/starbucks/src/main/java/example/springdata/rest/stores/StoreRepository.java +++ b/rest/starbucks/src/main/java/example/springdata/rest/stores/StoreRepository.java @@ -24,6 +24,7 @@ import org.springframework.data.geo.Point; import org.springframework.data.querydsl.QuerydslPredicateExecutor; import org.springframework.data.querydsl.binding.QuerydslBindings; import org.springframework.data.querydsl.binding.SingleValueBinding; +import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.rest.core.annotation.RestResource; @@ -36,7 +37,8 @@ import com.querydsl.core.types.dsl.StringPath; * * @author Oliver Gierke */ -public interface StoreRepository extends PagingAndSortingRepository, QuerydslPredicateExecutor { +public interface StoreRepository + extends CrudRepository, PagingAndSortingRepository, QuerydslPredicateExecutor { @RestResource(rel = "by-location") Page findByAddressLocationNear(Point location, Distance distance, Pageable pageable); diff --git a/rest/starbucks/src/main/resources/application.properties b/rest/starbucks/src/main/resources/application.properties index f644711a..1e5a96cc 100644 --- a/rest/starbucks/src/main/resources/application.properties +++ b/rest/starbucks/src/main/resources/application.properties @@ -1,5 +1,2 @@ -# Random port for embedded MongoDB -spring.data.mongodb.port=0 -spring.mongodb.embedded.version=3.6.0 # Spring Data REST spring.data.rest.base-path=/api diff --git a/rest/starbucks/src/test/java/example/springdata/rest/stores/StarbucksClient.java b/rest/starbucks/src/test/java/example/springdata/rest/stores/StarbucksClient.java index 3e6d5ff1..f03b6366 100644 --- a/rest/starbucks/src/test/java/example/springdata/rest/stores/StarbucksClient.java +++ b/rest/starbucks/src/test/java/example/springdata/rest/stores/StarbucksClient.java @@ -29,7 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.context.annotation.Bean; import org.springframework.hateoas.EntityModel; import org.springframework.hateoas.MediaTypes; @@ -126,8 +126,7 @@ class StarbucksClient { return String.format("%s, %s %s - lat: %s, long: %s", street, zip, city, location.y, location.x); } - record Location(double x, double y) { - } + record Location(double x, double y) {} } } }