diff --git a/elasticsearch/pom.xml b/elasticsearch/pom.xml index 2709a282..116ed244 100644 --- a/elasticsearch/pom.xml +++ b/elasticsearch/pom.xml @@ -30,7 +30,13 @@ spring-data-next-releasetrain - 6.5.0 + 6.6.0 + + + + spring-data-next-releasetrain-released + + 6.6.0 diff --git a/jdbc/basics/pom.xml b/jdbc/basics/pom.xml index ec70bbce..47056a01 100644 --- a/jdbc/basics/pom.xml +++ b/jdbc/basics/pom.xml @@ -13,5 +13,12 @@ Spring Data JDBC - Basic usage examples Sample project demonstrating Spring Data JDBC features + + + + org.springframework.boot + spring-boot-starter-web + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index e59f00de..ad2e24d1 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ 1.1.3 - 1.18.0 + 1.18.4 @@ -49,12 +49,16 @@ spring-data-next-releasetrain Moore-BUILD-SNAPSHOT + 1.0.0.BUILD-SNAPSHOT + 2.0.0.BUILD-SNAPSHOT spring-data-next-releasetrain-released - Lovelace-SR3 + Moore-M2 + 1.0.0.M1 + 2.0.0.M1 diff --git a/rest/starbucks/src/main/java/example/springdata/rest/stores/web/StoresController.java b/rest/starbucks/src/main/java/example/springdata/rest/stores/web/StoresController.java index 75f99be6..84a6a5a0 100644 --- a/rest/starbucks/src/main/java/example/springdata/rest/stores/web/StoresController.java +++ b/rest/starbucks/src/main/java/example/springdata/rest/stores/web/StoresController.java @@ -34,6 +34,7 @@ import org.springframework.data.geo.Distance; import org.springframework.data.geo.Metrics; import org.springframework.data.geo.Point; import org.springframework.data.rest.webmvc.support.RepositoryEntityLinks; +import org.springframework.hateoas.LinkRelation; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; @@ -89,7 +90,8 @@ class StoresController { model.addAttribute("selectedDistance", distance.orElse(DEFAULT_DISTANCE)); model.addAttribute("location", point); model.addAttribute("locations", KNOWN_LOCATIONS); - model.addAttribute("api", entityLinks.linkToSearchResource(Store.class, "by-location", pageable).getHref()); + model.addAttribute("api", + entityLinks.linkToSearchResource(Store.class, LinkRelation.of("by-location"), pageable).getHref()); return "index"; } 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 28549fbe..6fd0d991 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 @@ -1,5 +1,5 @@ /* - * Copyright 2014-2018 the original author or authors. + * Copyright 2014-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,18 +32,18 @@ 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.context.annotation.Bean; +import org.springframework.hateoas.CollectionModel; +import org.springframework.hateoas.EntityModel; import org.springframework.hateoas.Link; import org.springframework.hateoas.Links; import org.springframework.hateoas.MediaTypes; -import org.springframework.hateoas.PagedResources; -import org.springframework.hateoas.PagedResources.PageMetadata; -import org.springframework.hateoas.Resource; -import org.springframework.hateoas.Resources; +import org.springframework.hateoas.PagedModel; +import org.springframework.hateoas.PagedModel.PageMetadata; import org.springframework.hateoas.client.Traverson; import org.springframework.hateoas.client.Traverson.TraversalBuilder; -import org.springframework.hateoas.mvc.TypeReferences.PagedResourcesType; -import org.springframework.hateoas.mvc.TypeReferences.ResourceType; -import org.springframework.hateoas.mvc.TypeReferences.ResourcesType; +import org.springframework.hateoas.server.core.TypeReferences.CollectionModelType; +import org.springframework.hateoas.server.core.TypeReferences.EntityModelType; +import org.springframework.hateoas.server.core.TypeReferences.PagedModelType; import org.springframework.http.RequestEntity; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.client.RestOperations; @@ -90,16 +90,16 @@ public class StarbucksClient { parameters.put("location", "40.740337,-73.995146"); parameters.put("distance", "0.5miles"); - PagedResources> resources = builder.// + PagedModel> resources = builder.// withTemplateParameters(parameters).// - toObject(new PagedResourcesType>() {}); + toObject(new PagedModelType>() {}); PageMetadata metadata = resources.getMetadata(); log.info("Got {} of {} stores: ", resources.getContent().size(), metadata.getTotalElements()); StreamSupport.stream(resources.spliterator(), false).// - map(Resource::getContent).// + map(EntityModel::getContent).// forEach(store -> log.info("{} - {}", store.name, store.address)); } @@ -112,14 +112,15 @@ public class StarbucksClient { URI uri = URI.create(String.format(SERVICE_URI, port)); RequestEntity request = RequestEntity.get(uri).accept(HAL_JSON).build(); - Resource rootLinks = restOperations.exchange(request, new ResourceType() {}).getBody(); - Links links = new Links(rootLinks.getLinks()); + EntityModel rootLinks = restOperations.exchange(request, new EntityModelType() {}).getBody(); + Links links = rootLinks.getLinks(); // Follow stores link - Link storesLink = links.getLink("stores").expand(); + Link storesLink = links.getRequiredLink("stores").expand(); + request = RequestEntity.get(URI.create(storesLink.getHref())).accept(HAL_JSON).build(); - Resources stores = restOperations.exchange(request, new ResourcesType() {}).getBody(); + CollectionModel stores = restOperations.exchange(request, new CollectionModelType() {}).getBody(); stores.getContent().forEach(store -> log.info("{} - {}", store.name, store.address)); } diff --git a/rest/uri-customization/src/main/java/example/springdata/rest/uris/SpringDataRestCustomization.java b/rest/uri-customization/src/main/java/example/springdata/rest/uris/SpringDataRestCustomization.java index d7ef6c64..4eecedd5 100644 --- a/rest/uri-customization/src/main/java/example/springdata/rest/uris/SpringDataRestCustomization.java +++ b/rest/uri-customization/src/main/java/example/springdata/rest/uris/SpringDataRestCustomization.java @@ -16,7 +16,7 @@ package example.springdata.rest.uris; import org.springframework.data.rest.core.config.RepositoryRestConfiguration; -import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurerAdapter; +import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer; import org.springframework.stereotype.Component; /** @@ -25,16 +25,16 @@ import org.springframework.stereotype.Component; * @author Oliver Gierke */ @Component -public class SpringDataRestCustomization extends RepositoryRestConfigurerAdapter { +public class SpringDataRestCustomization implements RepositoryRestConfigurer { /* * (non-Javadoc) - * @see org.springframework.data.rest.webmvc.config.RepositoryRestConfigurerAdapter#configureRepositoryRestConfiguration(org.springframework.data.rest.core.config.RepositoryRestConfiguration) + * @see org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer#configureRepositoryRestConfiguration(org.springframework.data.rest.core.config.RepositoryRestConfiguration) */ @Override public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { - config.withEntityLookup().// - forRepository(UserRepository.class, User::getUsername, UserRepository::findByUsername); + config.withEntityLookup() // + .forRepository(UserRepository.class, User::getUsername, UserRepository::findByUsername); } } diff --git a/rest/uri-customization/src/main/java/example/springdata/rest/uris/User.java b/rest/uri-customization/src/main/java/example/springdata/rest/uris/User.java index 2ec2f594..20131cb2 100644 --- a/rest/uri-customization/src/main/java/example/springdata/rest/uris/User.java +++ b/rest/uri-customization/src/main/java/example/springdata/rest/uris/User.java @@ -16,6 +16,7 @@ package example.springdata.rest.uris; import lombok.Value; +import lombok.experimental.NonFinal; import java.util.UUID; @@ -26,6 +27,7 @@ import org.springframework.data.annotation.Id; * * @author Oliver Gierke */ +@NonFinal @Value public class User { diff --git a/rest/uri-customization/src/main/java/example/springdata/rest/uris/UserEntityLookup.java b/rest/uri-customization/src/main/java/example/springdata/rest/uris/UserEntityLookup.java index ce6e4673..7f4ac148 100644 --- a/rest/uri-customization/src/main/java/example/springdata/rest/uris/UserEntityLookup.java +++ b/rest/uri-customization/src/main/java/example/springdata/rest/uris/UserEntityLookup.java @@ -26,7 +26,7 @@ import org.springframework.data.rest.core.support.EntityLookupSupport; /** * Custom {@link EntityLookup} to replace the usage of the database identifier in item resource URIs with the username * property of the {@link User}. This one is not really used out of the box as it's not a Spring bean. It's just a - * sample of how to deploy a customization in non-Java 8 environments which can't use the fluent API in use in + * sample of how to deploy a customization in pre-Java 8 environments which can't use the fluent API in use in * {@link SpringDataRestCustomization}. * * @author Oliver Gierke @@ -54,4 +54,13 @@ public class UserEntityLookup extends EntityLookupSupport { public Optional lookupEntity(Object id) { return repository.findByUsername(id.toString()); } + + /* + * (non-Javadoc) + * @see org.springframework.data.rest.core.support.EntityLookup#getLookupProperty() + */ + @Override + public Optional getLookupProperty() { + return Optional.of("username"); + } }