Cleanup SD REST Starbucks example.

This commit is contained in:
Oliver Drotbohm
2024-08-15 16:00:29 +02:00
parent f14747a56d
commit c6a0e2e346
6 changed files with 11 additions and 14 deletions

View File

@@ -15,7 +15,7 @@
<description>Sample projects for Spring Data REST</description> <description>Sample projects for Spring Data REST</description>
<modules> <modules>
<!-- <module>starbucks</module> --> <module>starbucks</module>
<!-- <module>multi-store</module> --> <!-- <module>multi-store</module> -->
<module>projections</module> <module>projections</module>
<module>security</module> <module>security</module>

View File

@@ -22,6 +22,7 @@
<dependency> <dependency>
<groupId>de.flapdoodle.embed</groupId> <groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId> <artifactId>de.flapdoodle.embed.mongo</artifactId>
<version>4.16.2</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
@@ -69,14 +70,14 @@
<dependency> <dependency>
<groupId>org.webjars</groupId> <groupId>org.webjars</groupId>
<artifactId>jquery</artifactId> <artifactId>jquery</artifactId>
<version>2.1.3</version> <version>3.7.1</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.webjars</groupId> <groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId> <artifactId>bootstrap</artifactId>
<version>3.3.4</version> <version>5.3.3</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>

View File

@@ -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.mapping.DefaultLineMapper;
import org.springframework.batch.item.file.separator.DefaultRecordSeparatorPolicy; import org.springframework.batch.item.file.separator.DefaultRecordSeparatorPolicy;
import org.springframework.batch.item.file.transform.DelimitedLineTokenizer; import org.springframework.batch.item.file.transform.DelimitedLineTokenizer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.data.geo.Point; import org.springframework.data.geo.Point;
import org.springframework.data.mongodb.core.MongoOperations; import org.springframework.data.mongodb.core.MongoOperations;
@@ -45,7 +44,6 @@ import org.springframework.stereotype.Component;
@Component @Component
public class StoreInitializer { public class StoreInitializer {
@Autowired
public StoreInitializer(StoreRepository repository, MongoOperations operations) throws Exception { public StoreInitializer(StoreRepository repository, MongoOperations operations) throws Exception {
if (repository.count() != 0) { 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 * Reads a file {@code starbucks.csv} from the class path and parses it into {@link Store} instances about to be
* be persisted. * persisted.
* *
* @return * @return
* @throws Exception * @throws Exception

View File

@@ -24,6 +24,7 @@ import org.springframework.data.geo.Point;
import org.springframework.data.querydsl.QuerydslPredicateExecutor; import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.querydsl.binding.QuerydslBindings; import org.springframework.data.querydsl.binding.QuerydslBindings;
import org.springframework.data.querydsl.binding.SingleValueBinding; import org.springframework.data.querydsl.binding.SingleValueBinding;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.rest.core.annotation.RestResource; import org.springframework.data.rest.core.annotation.RestResource;
@@ -36,7 +37,8 @@ import com.querydsl.core.types.dsl.StringPath;
* *
* @author Oliver Gierke * @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") @RestResource(rel = "by-location")
Page<Store> findByAddressLocationNear(Point location, Distance distance, Pageable pageable); Page<Store> findByAddressLocationNear(Point location, Distance distance, Pageable pageable);

View File

@@ -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
spring.data.rest.base-path=/api spring.data.rest.base-path=/api

View File

@@ -29,7 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; 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.context.annotation.Bean;
import org.springframework.hateoas.EntityModel; import org.springframework.hateoas.EntityModel;
import org.springframework.hateoas.MediaTypes; 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); 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) {}
}
} }
} }
} }