Create spring-boot-hateoas module
This commit is contained in:
committed by
Phillip Webb
parent
1abf9c5f6c
commit
31c9d3c17a
@@ -65,6 +65,7 @@ include "spring-boot-project:spring-boot-freemarker"
|
||||
include "spring-boot-project:spring-boot-groovy-templates"
|
||||
include "spring-boot-project:spring-boot-gson"
|
||||
include "spring-boot-project:spring-boot-h2console"
|
||||
include "spring-boot-project:spring-boot-hateoas"
|
||||
include "spring-boot-project:spring-boot-hazelcast"
|
||||
include "spring-boot-project:spring-boot-integration"
|
||||
include "spring-boot-project:spring-boot-jackson"
|
||||
|
||||
@@ -147,6 +147,7 @@ dependencies {
|
||||
optional("org.springframework.session:spring-session-core")
|
||||
optional("redis.clients:jedis")
|
||||
|
||||
testImplementation(project(":spring-boot-project:spring-boot-hateoas"))
|
||||
testImplementation(project(":spring-boot-project:spring-boot-test"))
|
||||
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
|
||||
testImplementation(testFixtures(project(":spring-boot-project:spring-boot")))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 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,11 +32,11 @@ import org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandl
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
|
||||
import org.springframework.boot.hateoas.autoconfigure.HypermediaAutoConfiguration;
|
||||
import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration;
|
||||
import org.springframework.boot.test.util.TestPropertyValues;
|
||||
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext;
|
||||
|
||||
@@ -35,7 +35,6 @@ org.springframework.boot.autoconfigure.graphql.rsocket.RSocketGraphQlClientAutoC
|
||||
org.springframework.boot.autoconfigure.graphql.security.GraphQlWebFluxSecurityAutoConfiguration
|
||||
org.springframework.boot.autoconfigure.graphql.security.GraphQlWebMvcSecurityAutoConfiguration
|
||||
org.springframework.boot.autoconfigure.graphql.servlet.GraphQlWebMvcAutoConfiguration
|
||||
org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration
|
||||
org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration
|
||||
org.springframework.boot.autoconfigure.http.client.HttpClientAutoConfiguration
|
||||
org.springframework.boot.autoconfigure.http.client.service.HttpServiceClientAutoConfiguration
|
||||
|
||||
@@ -1998,6 +1998,7 @@ bom {
|
||||
"spring-boot-groovy-templates",
|
||||
"spring-boot-gson",
|
||||
"spring-boot-h2console",
|
||||
"spring-boot-hateoas",
|
||||
"spring-boot-hazelcast",
|
||||
"spring-boot-integration",
|
||||
"spring-boot-jackson",
|
||||
|
||||
@@ -77,6 +77,7 @@ dependencies {
|
||||
autoConfiguration(project(path: ":spring-boot-project:spring-boot-freemarker", configuration: "autoConfigurationMetadata"))
|
||||
autoConfiguration(project(path: ":spring-boot-project:spring-boot-gson", configuration: "autoConfigurationMetadata"))
|
||||
autoConfiguration(project(path: ":spring-boot-project:spring-boot-h2console", configuration: "autoConfigurationMetadata"))
|
||||
autoConfiguration(project(path: ":spring-boot-project:spring-boot-hateoas", configuration: "autoConfigurationMetadata"))
|
||||
autoConfiguration(project(path: ":spring-boot-project:spring-boot-hazelcast", configuration: "autoConfigurationMetadata"))
|
||||
autoConfiguration(project(path: ":spring-boot-project:spring-boot-integration", configuration: "autoConfigurationMetadata"))
|
||||
autoConfiguration(project(path: ":spring-boot-project:spring-boot-jackson", configuration: "autoConfigurationMetadata"))
|
||||
@@ -127,6 +128,7 @@ dependencies {
|
||||
configurationProperties(project(path: ":spring-boot-project:spring-boot-freemarker", configuration: "configurationPropertiesMetadata"))
|
||||
configurationProperties(project(path: ":spring-boot-project:spring-boot-gson", configuration: "configurationPropertiesMetadata"))
|
||||
configurationProperties(project(path: ":spring-boot-project:spring-boot-h2console", configuration: "configurationPropertiesMetadata"))
|
||||
configurationProperties(project(path: ":spring-boot-project:spring-boot-hateoas", configuration: "configurationPropertiesMetadata"))
|
||||
configurationProperties(project(path: ":spring-boot-project:spring-boot-hazelcast", configuration: "configurationPropertiesMetadata"))
|
||||
configurationProperties(project(path: ":spring-boot-project:spring-boot-integration", configuration: "configurationPropertiesMetadata"))
|
||||
configurationProperties(project(path: ":spring-boot-project:spring-boot-jackson", configuration: "configurationPropertiesMetadata"))
|
||||
|
||||
25
spring-boot-project/spring-boot-hateoas/build.gradle
Normal file
25
spring-boot-project/spring-boot-hateoas/build.gradle
Normal file
@@ -0,0 +1,25 @@
|
||||
plugins {
|
||||
id "java-library"
|
||||
id "org.springframework.boot.auto-configuration"
|
||||
id "org.springframework.boot.configuration-properties"
|
||||
id "org.springframework.boot.deployed"
|
||||
id "org.springframework.boot.optional-dependencies"
|
||||
}
|
||||
|
||||
description = "Spring Boot Hateoas"
|
||||
|
||||
dependencies {
|
||||
api(project(":spring-boot-project:spring-boot"))
|
||||
api("org.springframework.hateoas:spring-hateoas")
|
||||
|
||||
implementation("com.fasterxml.jackson.core:jackson-databind")
|
||||
implementation("org.springframework:spring-webmvc")
|
||||
|
||||
optional(project(":spring-boot-project:spring-boot-autoconfigure"))
|
||||
|
||||
testImplementation(project(":spring-boot-project:spring-boot-test"))
|
||||
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
|
||||
testImplementation("jakarta.servlet:jakarta.servlet-api")
|
||||
|
||||
testRuntimeOnly("ch.qos.logback:logback-classic")
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.hateoas;
|
||||
package org.springframework.boot.hateoas.autoconfigure;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.2.1
|
||||
* @since 4.0.0
|
||||
*/
|
||||
@ConfigurationProperties("spring.hateoas")
|
||||
public class HateoasProperties {
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.hateoas;
|
||||
package org.springframework.boot.hateoas.autoconfigure;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
@@ -24,9 +24,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProp
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -47,20 +44,17 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
|
||||
* @author Roy Clarkson
|
||||
* @author Oliver Gierke
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.1.0
|
||||
* @since 4.0.0
|
||||
*/
|
||||
@AutoConfiguration(
|
||||
after = { WebMvcAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class,
|
||||
RepositoryRestMvcAutoConfiguration.class },
|
||||
afterName = "org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration")
|
||||
@ConditionalOnClass({ EntityModel.class, RequestMapping.class, RequestMappingHandlerAdapter.class, Plugin.class })
|
||||
@AutoConfiguration
|
||||
@ConditionalOnClass({ EntityModel.class, RequestMapping.class, RequestMappingHandlerAdapter.class, Plugin.class,
|
||||
ObjectMapper.class })
|
||||
@ConditionalOnWebApplication
|
||||
@EnableConfigurationProperties(HateoasProperties.class)
|
||||
public class HypermediaAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnClass(name = "com.fasterxml.jackson.databind.ObjectMapper")
|
||||
@ConditionalOnBooleanProperty(name = "spring.hateoas.use-hal-as-default-json-media-type", matchIfMissing = true)
|
||||
HalConfiguration applicationJsonHalConfiguration() {
|
||||
return new HalConfiguration().withMediaType(MediaType.APPLICATION_JSON);
|
||||
@@ -68,9 +62,8 @@ public class HypermediaAutoConfiguration {
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnMissingBean(LinkDiscoverers.class)
|
||||
@ConditionalOnClass(ObjectMapper.class)
|
||||
@EnableHypermediaSupport(type = HypermediaType.HAL)
|
||||
protected static class HypermediaConfiguration {
|
||||
static class HypermediaConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2025 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.
|
||||
@@ -17,4 +17,4 @@
|
||||
/**
|
||||
* Auto-configuration for Spring HATEOAS.
|
||||
*/
|
||||
package org.springframework.boot.autoconfigure.hateoas;
|
||||
package org.springframework.boot.hateoas.autoconfigure;
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"groups": [],
|
||||
"properties": []
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
org.springframework.boot.hateoas.autoconfigure.HypermediaAutoConfiguration
|
||||
@@ -14,17 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.hateoas;
|
||||
package org.springframework.boot.hateoas.autoconfigure;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration.HypermediaConfiguration;
|
||||
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
|
||||
import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration;
|
||||
import org.springframework.boot.hateoas.autoconfigure.HypermediaAutoConfiguration.HypermediaConfiguration;
|
||||
import org.springframework.boot.test.context.FilteredClassLoader;
|
||||
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -38,6 +35,7 @@ import org.springframework.hateoas.mediatype.hal.HalLinkDiscoverer;
|
||||
import org.springframework.hateoas.server.EntityLinks;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -117,8 +115,8 @@ class HypermediaAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@ImportAutoConfiguration({ HttpMessageConvertersAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
||||
JacksonAutoConfiguration.class, HypermediaAutoConfiguration.class })
|
||||
@EnableWebMvc
|
||||
@ImportAutoConfiguration(HypermediaAutoConfiguration.class)
|
||||
static class BaseConfig {
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2025 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.
|
||||
@@ -14,13 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.hateoas;
|
||||
package org.springframework.boot.hateoas.autoconfigure;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
|
||||
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
|
||||
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext;
|
||||
import org.springframework.mock.web.MockServletContext;
|
||||
@@ -43,8 +41,7 @@ class HypermediaAutoConfigurationWithoutJacksonTests {
|
||||
this.context.refresh();
|
||||
}
|
||||
|
||||
@ImportAutoConfiguration({ HttpMessageConvertersAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
||||
HypermediaAutoConfiguration.class })
|
||||
@ImportAutoConfiguration(HypermediaAutoConfiguration.class)
|
||||
static class BaseConfig {
|
||||
|
||||
}
|
||||
@@ -5,6 +5,6 @@ plugins {
|
||||
description = "Starter for building hypermedia-based RESTful web application with Spring MVC and Spring HATEOAS"
|
||||
|
||||
dependencies {
|
||||
api(project(":spring-boot-project:spring-boot-hateoas"))
|
||||
api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web"))
|
||||
api("org.springframework.hateoas:spring-hateoas")
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ dependencies {
|
||||
optional(project(":spring-boot-project:spring-boot-elasticsearch"))
|
||||
optional(project(":spring-boot-project:spring-boot-flyway"))
|
||||
optional(project(":spring-boot-project:spring-boot-groovy-templates"))
|
||||
optional(project(":spring-boot-project:spring-boot-hateoas"))
|
||||
optional(project(":spring-boot-project:spring-boot-jackson"))
|
||||
optional(project(":spring-boot-project:spring-boot-jdbc"))
|
||||
optional(project(":spring-boot-project:spring-boot-jooq"))
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
# AutoConfigureWebMvc auto-configuration imports
|
||||
optional:org.springframework.boot.freemarker.autoconfigure.FreeMarkerAutoConfiguration
|
||||
optional:org.springframework.boot.groovy.template.autoconfigure.GroovyTemplateAutoConfiguration
|
||||
optional:org.springframework.boot.hateoas.autoconfigure.HypermediaAutoConfiguration
|
||||
optional:org.springframework.boot.mustache.autoconfigure.MustacheAutoConfiguration
|
||||
optional:org.springframework.boot.thymeleaf.autoconfigure.ThymeleafAutoConfiguration
|
||||
optional:org.springframework.boot.validation.autoconfigure.ValidationAutoConfiguration
|
||||
org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration
|
||||
org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration
|
||||
optional:org.springframework.boot.freemarker.autoconfigure.FreeMarkerAutoConfiguration
|
||||
org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration
|
||||
org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration
|
||||
optional:org.springframework.boot.mustache.autoconfigure.MustacheAutoConfiguration
|
||||
org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration
|
||||
optional:org.springframework.boot.thymeleaf.autoconfigure.ThymeleafAutoConfiguration
|
||||
optional:org.springframework.boot.groovy.template.autoconfigure.GroovyTemplateAutoConfiguration
|
||||
optional:org.springframework.boot.validation.autoconfigure.ValidationAutoConfiguration
|
||||
org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration
|
||||
org.springframework.boot.autoconfigure.web.servlet.HttpEncodingAutoConfiguration
|
||||
org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration
|
||||
|
||||
Reference in New Issue
Block a user