Skip to content

Commit 20164d8

Browse files
committed
Create spring-boot-hateoas module
1 parent 30b5e29 commit 20164d8

File tree

17 files changed

+64
-41
lines changed

17 files changed

+64
-41
lines changed

settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ include "spring-boot-project:spring-boot-freemarker"
6565
include "spring-boot-project:spring-boot-groovy-templates"
6666
include "spring-boot-project:spring-boot-gson"
6767
include "spring-boot-project:spring-boot-h2"
68+
include "spring-boot-project:spring-boot-hateoas"
6869
include "spring-boot-project:spring-boot-hazelcast"
6970
include "spring-boot-project:spring-boot-integration"
7071
include "spring-boot-project:spring-boot-jackson"

spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ dependencies {
156156
optional("org.springframework.session:spring-session-core")
157157
optional("redis.clients:jedis")
158158

159+
testImplementation(project(":spring-boot-project:spring-boot-hateoas"))
159160
testImplementation(project(":spring-boot-project:spring-boot-test"))
160161
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
161162
testImplementation(testFixtures(project(":spring-boot-project:spring-boot")))

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointIntegrationTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,11 +32,11 @@
3232
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
3333
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
3434
import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration;
35-
import org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration;
3635
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
3736
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
3837
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration;
3938
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
39+
import org.springframework.boot.hateoas.autoconfigure.HypermediaAutoConfiguration;
4040
import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration;
4141
import org.springframework.boot.test.util.TestPropertyValues;
4242
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext;

spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ org.springframework.boot.autoconfigure.graphql.rsocket.RSocketGraphQlClientAutoC
3535
org.springframework.boot.autoconfigure.graphql.security.GraphQlWebFluxSecurityAutoConfiguration
3636
org.springframework.boot.autoconfigure.graphql.security.GraphQlWebMvcSecurityAutoConfiguration
3737
org.springframework.boot.autoconfigure.graphql.servlet.GraphQlWebMvcAutoConfiguration
38-
org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration
3938
org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration
4039
org.springframework.boot.autoconfigure.http.client.HttpClientAutoConfiguration
4140
org.springframework.boot.autoconfigure.http.codec.CodecsAutoConfiguration

spring-boot-project/spring-boot-dependencies/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -2008,6 +2008,7 @@ bom {
20082008
"spring-boot-groovy-templates",
20092009
"spring-boot-gson",
20102010
"spring-boot-h2",
2011+
"spring-boot-hateoas",
20112012
"spring-boot-hazelcast",
20122013
"spring-boot-integration",
20132014
"spring-boot-jackson",

spring-boot-project/spring-boot-docs/build.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ dependencies {
7171
autoConfiguration(project(path: ":spring-boot-project:spring-boot-freemarker", configuration: "autoConfigurationMetadata"))
7272
autoConfiguration(project(path: ":spring-boot-project:spring-boot-gson", configuration: "autoConfigurationMetadata"))
7373
autoConfiguration(project(path: ":spring-boot-project:spring-boot-h2", configuration: "autoConfigurationMetadata"))
74+
autoConfiguration(project(path: ":spring-boot-project:spring-boot-hateoas", configuration: "autoConfigurationMetadata"))
7475
autoConfiguration(project(path: ":spring-boot-project:spring-boot-hazelcast", configuration: "autoConfigurationMetadata"))
7576
autoConfiguration(project(path: ":spring-boot-project:spring-boot-integration", configuration: "autoConfigurationMetadata"))
7677
autoConfiguration(project(path: ":spring-boot-project:spring-boot-jackson", configuration: "autoConfigurationMetadata"))
@@ -121,6 +122,7 @@ dependencies {
121122
configurationProperties(project(path: ":spring-boot-project:spring-boot-freemarker", configuration: "configurationPropertiesMetadata"))
122123
configurationProperties(project(path: ":spring-boot-project:spring-boot-gson", configuration: "configurationPropertiesMetadata"))
123124
configurationProperties(project(path: ":spring-boot-project:spring-boot-h2", configuration: "configurationPropertiesMetadata"))
125+
configurationProperties(project(path: ":spring-boot-project:spring-boot-hateoas", configuration: "configurationPropertiesMetadata"))
124126
configurationProperties(project(path: ":spring-boot-project:spring-boot-hazelcast", configuration: "configurationPropertiesMetadata"))
125127
configurationProperties(project(path: ":spring-boot-project:spring-boot-integration", configuration: "configurationPropertiesMetadata"))
126128
configurationProperties(project(path: ":spring-boot-project:spring-boot-jackson", configuration: "configurationPropertiesMetadata"))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
plugins {
2+
id "java-library"
3+
id "org.springframework.boot.auto-configuration"
4+
id "org.springframework.boot.configuration-properties"
5+
id "org.springframework.boot.deployed"
6+
id "org.springframework.boot.optional-dependencies"
7+
}
8+
9+
description = "Spring Boot Hateoas"
10+
11+
dependencies {
12+
api(project(":spring-boot-project:spring-boot"))
13+
api("org.springframework.hateoas:spring-hateoas")
14+
15+
implementation("com.fasterxml.jackson.core:jackson-databind")
16+
implementation("org.springframework:spring-webmvc")
17+
18+
optional(project(":spring-boot-project:spring-boot-autoconfigure"))
19+
20+
testImplementation(project(":spring-boot-project:spring-boot-test"))
21+
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
22+
testImplementation("jakarta.servlet:jakarta.servlet-api")
23+
24+
testRuntimeOnly("ch.qos.logback:logback-classic")
25+
}
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.hateoas;
17+
package org.springframework.boot.hateoas.autoconfigure;
1818

1919
import org.springframework.boot.context.properties.ConfigurationProperties;
2020

@@ -23,7 +23,7 @@
2323
*
2424
* @author Phillip Webb
2525
* @author Andy Wilkinson
26-
* @since 1.2.1
26+
* @since 4.0.0
2727
*/
2828
@ConfigurationProperties("spring.hateoas")
2929
public class HateoasProperties {
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.hateoas;
17+
package org.springframework.boot.hateoas.autoconfigure;
1818

1919
import com.fasterxml.jackson.databind.ObjectMapper;
2020

@@ -24,9 +24,6 @@
2424
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
2525
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
2626
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
27-
import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration;
28-
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
29-
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
3027
import org.springframework.boot.context.properties.EnableConfigurationProperties;
3128
import org.springframework.context.annotation.Bean;
3229
import org.springframework.context.annotation.Configuration;
@@ -47,30 +44,26 @@
4744
* @author Roy Clarkson
4845
* @author Oliver Gierke
4946
* @author Andy Wilkinson
50-
* @since 1.1.0
47+
* @since 4.0.0
5148
*/
52-
@AutoConfiguration(
53-
after = { WebMvcAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class,
54-
RepositoryRestMvcAutoConfiguration.class },
55-
afterName = "org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration")
56-
@ConditionalOnClass({ EntityModel.class, RequestMapping.class, RequestMappingHandlerAdapter.class, Plugin.class })
49+
@AutoConfiguration
50+
@ConditionalOnClass({ EntityModel.class, RequestMapping.class, RequestMappingHandlerAdapter.class, Plugin.class,
51+
ObjectMapper.class })
5752
@ConditionalOnWebApplication
5853
@EnableConfigurationProperties(HateoasProperties.class)
5954
public class HypermediaAutoConfiguration {
6055

6156
@Bean
6257
@ConditionalOnMissingBean
63-
@ConditionalOnClass(name = "com.fasterxml.jackson.databind.ObjectMapper")
6458
@ConditionalOnBooleanProperty(name = "spring.hateoas.use-hal-as-default-json-media-type", matchIfMissing = true)
6559
HalConfiguration applicationJsonHalConfiguration() {
6660
return new HalConfiguration().withMediaType(MediaType.APPLICATION_JSON);
6761
}
6862

6963
@Configuration(proxyBeanMethods = false)
7064
@ConditionalOnMissingBean(LinkDiscoverers.class)
71-
@ConditionalOnClass(ObjectMapper.class)
7265
@EnableHypermediaSupport(type = HypermediaType.HAL)
73-
protected static class HypermediaConfiguration {
66+
static class HypermediaConfiguration {
7467

7568
}
7669

Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,4 +17,4 @@
1717
/**
1818
* Auto-configuration for Spring HATEOAS.
1919
*/
20-
package org.springframework.boot.autoconfigure.hateoas;
20+
package org.springframework.boot.hateoas.autoconfigure;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"groups": [],
3+
"properties": []
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.springframework.boot.hateoas.autoconfigure.HypermediaAutoConfiguration
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,17 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.hateoas;
17+
package org.springframework.boot.hateoas.autoconfigure;
1818

1919
import java.util.Optional;
2020

2121
import org.junit.jupiter.api.Test;
2222

2323
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
24-
import org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration.HypermediaConfiguration;
25-
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
26-
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
27-
import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration;
24+
import org.springframework.boot.hateoas.autoconfigure.HypermediaAutoConfiguration.HypermediaConfiguration;
2825
import org.springframework.boot.test.context.FilteredClassLoader;
2926
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
3027
import org.springframework.context.annotation.Configuration;
@@ -39,6 +36,7 @@
3936
import org.springframework.http.MediaType;
4037
import org.springframework.http.converter.HttpMessageConverter;
4138
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
39+
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
4240
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
4341

4442
import static org.assertj.core.api.Assertions.assertThat;
@@ -116,8 +114,8 @@ void whenHalIsNotTheDefaultJsonMediaTypeThenMappingJacksonConverterCannotWriteHa
116114
});
117115
}
118116

119-
@ImportAutoConfiguration({ HttpMessageConvertersAutoConfiguration.class, WebMvcAutoConfiguration.class,
120-
JacksonAutoConfiguration.class, HypermediaAutoConfiguration.class })
117+
@EnableWebMvc
118+
@ImportAutoConfiguration(HypermediaAutoConfiguration.class)
121119
static class BaseConfig {
122120

123121
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,13 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.hateoas;
17+
package org.springframework.boot.hateoas.autoconfigure;
1818

1919
import org.junit.jupiter.api.Test;
2020

2121
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
22-
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
23-
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
2422
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
2523
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext;
2624
import org.springframework.mock.web.MockServletContext;
@@ -43,8 +41,7 @@ void jacksonRelatedConfigurationBacksOff() {
4341
this.context.refresh();
4442
}
4543

46-
@ImportAutoConfiguration({ HttpMessageConvertersAutoConfiguration.class, WebMvcAutoConfiguration.class,
47-
HypermediaAutoConfiguration.class })
44+
@ImportAutoConfiguration(HypermediaAutoConfiguration.class)
4845
static class BaseConfig {
4946

5047
}

spring-boot-project/spring-boot-starters/spring-boot-starter-hateoas/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ plugins {
55
description = "Starter for building hypermedia-based RESTful web application with Spring MVC and Spring HATEOAS"
66

77
dependencies {
8+
api(project(":spring-boot-project:spring-boot-hateoas"))
89
api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web"))
9-
api("org.springframework.hateoas:spring-hateoas")
1010
}

spring-boot-project/spring-boot-test-autoconfigure/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ dependencies {
4444
optional(project(":spring-boot-project:spring-boot-elasticsearch"))
4545
optional(project(":spring-boot-project:spring-boot-flyway"))
4646
optional(project(":spring-boot-project:spring-boot-groovy-templates"))
47+
optional(project(":spring-boot-project:spring-boot-hateoas"))
4748
optional(project(":spring-boot-project:spring-boot-jackson"))
4849
optional(project(":spring-boot-project:spring-boot-jdbc"))
4950
optional(project(":spring-boot-project:spring-boot-jooq"))
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# AutoConfigureWebMvc auto-configuration imports
2-
org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration
3-
org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration
42
optional:org.springframework.boot.freemarker.autoconfigure.FreeMarkerAutoConfiguration
5-
org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration
6-
org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration
3+
optional:org.springframework.boot.groovy.template.autoconfigure.GroovyTemplateAutoConfiguration
4+
optional:org.springframework.boot.hateoas.autoconfigure.HypermediaAutoConfiguration
75
optional:org.springframework.boot.mustache.autoconfigure.MustacheAutoConfiguration
8-
org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration
96
optional:org.springframework.boot.thymeleaf.autoconfigure.ThymeleafAutoConfiguration
10-
optional:org.springframework.boot.groovy.template.autoconfigure.GroovyTemplateAutoConfiguration
117
optional:org.springframework.boot.validation.autoconfigure.ValidationAutoConfiguration
8+
org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration
9+
org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration
10+
org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration
11+
org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration
1212
org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration
1313
org.springframework.boot.autoconfigure.web.servlet.HttpEncodingAutoConfiguration
1414
org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration

0 commit comments

Comments
 (0)