Cleanup SD REST Starbucks example.
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
<description>Sample projects for Spring Data REST</description>
|
||||
|
||||
<modules>
|
||||
<!-- <module>starbucks</module> -->
|
||||
<module>starbucks</module>
|
||||
<!-- <module>multi-store</module> -->
|
||||
<module>projections</module>
|
||||
<module>security</module>
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
<dependency>
|
||||
<groupId>de.flapdoodle.embed</groupId>
|
||||
<artifactId>de.flapdoodle.embed.mongo</artifactId>
|
||||
<version>4.16.2</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -69,14 +70,14 @@
|
||||
<dependency>
|
||||
<groupId>org.webjars</groupId>
|
||||
<artifactId>jquery</artifactId>
|
||||
<version>2.1.3</version>
|
||||
<version>3.7.1</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.webjars</groupId>
|
||||
<artifactId>bootstrap</artifactId>
|
||||
<version>3.3.4</version>
|
||||
<version>5.3.3</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<Store, UUID>, QuerydslPredicateExecutor<Store> {
|
||||
public interface StoreRepository
|
||||
extends CrudRepository<Store, UUID>, PagingAndSortingRepository<Store, UUID>, QuerydslPredicateExecutor<Store> {
|
||||
|
||||
@RestResource(rel = "by-location")
|
||||
Page<Store> findByAddressLocationNear(Point location, Distance distance, Pageable pageable);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user