diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/cloudfoundry/customcontextpath/MyCloudFoundryConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/cloudfoundry/customcontextpath/MyCloudFoundryConfiguration.kt index 9661ba1647a..eb73879c038 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/cloudfoundry/customcontextpath/MyCloudFoundryConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/cloudfoundry/customcontextpath/MyCloudFoundryConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,14 +24,24 @@ import org.springframework.boot.web.servlet.ServletContextInitializer import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import java.io.IOException -import javax.servlet.* +import java.util.Collections.emptySet +import javax.servlet.GenericServlet +import javax.servlet.Servlet +import javax.servlet.ServletContainerInitializer +import javax.servlet.ServletContext +import javax.servlet.ServletException +import javax.servlet.ServletRequest +import javax.servlet.ServletResponse import kotlin.jvm.Throws +@Suppress("UNUSED_ANONYMOUS_PARAMETER") @Configuration(proxyBeanMethods = false) class MyCloudFoundryConfiguration { + @Bean fun servletWebServerFactory(): TomcatServletWebServerFactory { return object : TomcatServletWebServerFactory() { + override fun prepareContext(host: Host, initializers: Array) { super.prepareContext(host, initializers) val child = StandardContext() @@ -42,17 +52,20 @@ class MyCloudFoundryConfiguration { child.crossContext = true host.addChild(child) } + } } private fun getServletContextInitializer(contextPath: String): ServletContainerInitializer { return ServletContainerInitializer { classes: Set?>?, context: ServletContext -> val servlet: Servlet = object : GenericServlet() { + @Throws(ServletException::class, IOException::class) override fun service(req: ServletRequest, res: ServletResponse) { - val context = req.servletContext.getContext(contextPath) - context.getRequestDispatcher("/cloudfoundryapplication").forward(req, res) + val servletContext = req.servletContext.getContext(contextPath) + servletContext.getRequestDispatcher("/cloudfoundryapplication").forward(req, res) } + } context.addServlet("cloudfoundry", servlet).addMapping("/*") } diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/health/reactivehealthindicators/MyReactiveHealthIndicator.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/health/reactivehealthindicators/MyReactiveHealthIndicator.kt index 028078d7dd5..ac8921719a4 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/health/reactivehealthindicators/MyReactiveHealthIndicator.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/health/reactivehealthindicators/MyReactiveHealthIndicator.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,18 +23,18 @@ import reactor.core.publisher.Mono @Component class MyReactiveHealthIndicator : ReactiveHealthIndicator { + override fun health(): Mono { // @formatter:off return doHealthCheck()!!.onErrorResume { exception: Throwable? -> - Mono.just( - Health.Builder().down(exception).build() - ) + Mono.just(Health.Builder().down(exception).build()) } // @formatter:on } private fun doHealthCheck(): Mono? { // perform some specific health check - return /**/null + return /**/ null } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/health/writingcustomhealthindicators/MyHealthIndicator.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/health/writingcustomhealthindicators/MyHealthIndicator.kt index 067e14e65bc..c200b001fec 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/health/writingcustomhealthindicators/MyHealthIndicator.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/health/writingcustomhealthindicators/MyHealthIndicator.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,15 +22,18 @@ import org.springframework.stereotype.Component @Component class MyHealthIndicator : HealthIndicator { + override fun health(): Health { val errorCode = check() - return if (errorCode != 0) { - Health.down().withDetail("Error Code", errorCode).build() - } else Health.up().build() + if (errorCode != 0) { + return Health.down().withDetail("Error Code", errorCode).build() + } + return Health.up().build() } private fun check(): Int { // perform some specific health check - return /**/0 + return /**/ 0 } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/implementingcustom/CustomData.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/implementingcustom/CustomData.kt index 75d489bbe2e..a6e467b6eed 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/implementingcustom/CustomData.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/implementingcustom/CustomData.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/implementingcustom/MyEndpoint.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/implementingcustom/MyEndpoint.kt index f1b4efd209a..4b0991857d8 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/implementingcustom/MyEndpoint.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/implementingcustom/MyEndpoint.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,16 +21,20 @@ import org.springframework.boot.actuate.endpoint.annotation.ReadOperation import org.springframework.boot.actuate.endpoint.annotation.WriteOperation @Endpoint(id = "custom") +@Suppress("UNUSED_PARAMETER") class MyEndpoint { - // tag::read[] - @get:ReadOperation - val data: CustomData - get() = CustomData("test", 5) + // tag::read[] + @ReadOperation + fun getData(): CustomData { + return CustomData("test", 5) + } // end::read[] + // tag::write[] @WriteOperation fun updateData(name: String?, counter: Int) { // injects "test" and 42 - } // end::write[] + } + // end::write[] } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/info/writingcustominfocontributors/MyInfoContributor.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/info/writingcustominfocontributors/MyInfoContributor.kt index 209c07e5c24..e8de417203a 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/info/writingcustominfocontributors/MyInfoContributor.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/info/writingcustominfocontributors/MyInfoContributor.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -19,11 +19,13 @@ package org.springframework.boot.docs.actuator.endpoints.info.writingcustominfoc import org.springframework.boot.actuate.info.Info import org.springframework.boot.actuate.info.InfoContributor import org.springframework.stereotype.Component -import java.util.* +import java.util.Collections @Component class MyInfoContributor : InfoContributor { + override fun contribute(builder: Info.Builder) { builder.withDetail("example", Collections.singletonMap("key", "value")) } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/security/exposeall/MySecurityConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/security/exposeall/MySecurityConfiguration.kt index 41ccd1bf928..f73ef895ee8 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/security/exposeall/MySecurityConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/security/exposeall/MySecurityConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -20,18 +20,16 @@ import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointR import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.security.config.annotation.web.builders.HttpSecurity -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry import org.springframework.security.web.SecurityFilterChain @Configuration(proxyBeanMethods = false) class MySecurityConfiguration { + @Bean fun securityFilterChain(http: HttpSecurity): SecurityFilterChain { - http.requestMatcher(EndpointRequest.toAnyEndpoint()) - .authorizeRequests { requests: ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry -> - requests.anyRequest().permitAll() - } + http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests { + requests -> requests.anyRequest().permitAll() } return http.build() } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/security/typical/MySecurityConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/security/typical/MySecurityConfiguration.kt index 3fd98ceb410..a777fd884a0 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/security/typical/MySecurityConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/security/typical/MySecurityConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -20,19 +20,18 @@ import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointR import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.security.config.annotation.web.builders.HttpSecurity -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry import org.springframework.security.web.SecurityFilterChain @Configuration(proxyBeanMethods = false) class MySecurityConfiguration { + @Bean fun securityFilterChain(http: HttpSecurity): SecurityFilterChain { - http.requestMatcher(EndpointRequest.toAnyEndpoint()) - .authorizeRequests { requests: ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry -> - requests.anyRequest().hasRole("ENDPOINT_ADMIN") - } + http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests { requests -> + requests.anyRequest().hasRole("ENDPOINT_ADMIN") + } http.httpBasic() return http.build() } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/customizing/MyMetricsFilterConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/customizing/MyMetricsFilterConfiguration.kt index 3e79533454f..ad874515a5e 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/customizing/MyMetricsFilterConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/customizing/MyMetricsFilterConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,8 +22,10 @@ import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) class MyMetricsFilterConfiguration { + @Bean fun renameRegionTagMeterFilter(): MeterFilter { return MeterFilter.renameTag("com.example", "mytag.region", "mytag.area") } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/export/graphite/MyGraphiteConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/export/graphite/MyGraphiteConfiguration.kt index 3e7d9ee8614..db4d88a602e 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/export/graphite/MyGraphiteConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/export/graphite/MyGraphiteConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -27,18 +27,13 @@ import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) class MyGraphiteConfiguration { + @Bean fun graphiteMeterRegistry(config: GraphiteConfig, clock: Clock): GraphiteMeterRegistry { - return GraphiteMeterRegistry(config, clock, - HierarchicalNameMapper { id: Meter.Id, convention: NamingConvention -> - toHierarchicalName( - id, - convention - ) - }) + return GraphiteMeterRegistry(config, clock, this::toHierarchicalName) + } + private fun toHierarchicalName(id: Meter.Id, convention: NamingConvention): String { + return /**/ HierarchicalNameMapper.DEFAULT.toHierarchicalName(id, convention) } - private fun toHierarchicalName(id: Meter.Id, convention: NamingConvention): String { - return /**/HierarchicalNameMapper.DEFAULT.toHierarchicalName(id, convention) - } } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/export/jmx/MyJmxConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/export/jmx/MyJmxConfiguration.kt index 58d910132f6..694d70cbffd 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/export/jmx/MyJmxConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/export/jmx/MyJmxConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -27,18 +27,14 @@ import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) class MyJmxConfiguration { + @Bean fun jmxMeterRegistry(config: JmxConfig, clock: Clock): JmxMeterRegistry { - return JmxMeterRegistry(config, clock, - HierarchicalNameMapper { id: Meter.Id, convention: NamingConvention -> - toHierarchicalName( - id, - convention - ) - }) + return JmxMeterRegistry(config, clock, this::toHierarchicalName) } private fun toHierarchicalName(id: Meter.Id, convention: NamingConvention): String { - return /**/HierarchicalNameMapper.DEFAULT.toHierarchicalName(id, convention) + return /**/ HierarchicalNameMapper.DEFAULT.toHierarchicalName(id, convention) } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/gettingstarted/commontags/MyMeterRegistryConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/gettingstarted/commontags/MyMeterRegistryConfiguration.kt index 05c6c150abe..708529b4a7b 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/gettingstarted/commontags/MyMeterRegistryConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/gettingstarted/commontags/MyMeterRegistryConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,10 +23,12 @@ import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) class MyMeterRegistryConfiguration { + @Bean fun metricsCommonTags(): MeterRegistryCustomizer { - return MeterRegistryCustomizer { registry: MeterRegistry -> + return MeterRegistryCustomizer { registry -> registry.config().commonTags("region", "us-east-1") } } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/gettingstarted/specifictype/MyMeterRegistryConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/gettingstarted/specifictype/MyMeterRegistryConfiguration.kt index c64dd7563ff..25ce06c220d 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/gettingstarted/specifictype/MyMeterRegistryConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/gettingstarted/specifictype/MyMeterRegistryConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -25,21 +25,16 @@ import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) class MyMeterRegistryConfiguration { + @Bean fun graphiteMetricsNamingConvention(): MeterRegistryCustomizer { return MeterRegistryCustomizer { registry: GraphiteMeterRegistry -> - registry.config().namingConvention( - NamingConvention { name: String?, type: Meter.Type?, baseUnit: String? -> - name( - name!!, - type!!, - baseUnit - ) - }) + registry.config().namingConvention(this::name) } } private fun name(name: String, type: Meter.Type, baseUnit: String?): String { - return /**/NamingConvention.snakeCase.name(name, type, baseUnit) + return /**/ NamingConvention.snakeCase.name(name, type, baseUnit) } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/registeringcustom/Dictionary.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/registeringcustom/Dictionary.kt index 20aa0cc4bb8..f91ed337870 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/registeringcustom/Dictionary.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/registeringcustom/Dictionary.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,6 +17,7 @@ package org.springframework.boot.docs.actuator.metrics.registeringcustom internal class Dictionary { + val words: List get() = emptyList() @@ -25,4 +26,5 @@ internal class Dictionary { return Dictionary() } } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/registeringcustom/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/registeringcustom/MyBean.kt index 152d3e61839..4875a310895 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/registeringcustom/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/registeringcustom/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,10 +22,12 @@ import org.springframework.stereotype.Component @Component class MyBean(registry: MeterRegistry) { + private val dictionary: Dictionary init { dictionary = Dictionary.load() registry.gauge("dictionary.size", Tags.empty(), dictionary.words.size) } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/registeringcustom/MyMeterBinderConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/registeringcustom/MyMeterBinderConfiguration.kt index 34b70204a7f..3af700261bd 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/registeringcustom/MyMeterBinderConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/registeringcustom/MyMeterBinderConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,17 +17,16 @@ package org.springframework.boot.docs.actuator.metrics.registeringcustom import io.micrometer.core.instrument.Gauge -import io.micrometer.core.instrument.MeterRegistry import io.micrometer.core.instrument.binder.MeterBinder import org.springframework.context.annotation.Bean class MyMeterBinderConfiguration { + @Bean fun queueSize(queue: Queue): MeterBinder { - return MeterBinder { registry: MeterRegistry -> - Gauge.builder( - "queueSize" - ) { queue.size() }.register(registry) + return MeterBinder { registry -> + Gauge.builder("queueSize", queue::size).register(registry) } } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/registeringcustom/Queue.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/registeringcustom/Queue.kt index 8338b829323..c51fd54f7af 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/registeringcustom/Queue.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/registeringcustom/Queue.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,7 +17,9 @@ package org.springframework.boot.docs.actuator.metrics.registeringcustom class Queue { + fun size(): Int { return 5 } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/mongodb/command/CustomCommandTagsProvider.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/mongodb/command/CustomCommandTagsProvider.kt index a99d3b90e32..7c49e6e6c4e 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/mongodb/command/CustomCommandTagsProvider.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/mongodb/command/CustomCommandTagsProvider.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,7 +21,9 @@ import io.micrometer.core.instrument.Tag import io.micrometer.core.instrument.binder.mongodb.MongoCommandTagsProvider class CustomCommandTagsProvider : MongoCommandTagsProvider { + override fun commandTags(commandEvent: CommandEvent): Iterable { return emptyList() } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/mongodb/command/MyCommandTagsProviderConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/mongodb/command/MyCommandTagsProviderConfiguration.kt index 2a303c0bc1c..f412eefcad2 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/mongodb/command/MyCommandTagsProviderConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/mongodb/command/MyCommandTagsProviderConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/mongodb/connectionpool/CustomConnectionPoolTagsProvider.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/mongodb/connectionpool/CustomConnectionPoolTagsProvider.kt index 6e3d8554144..b84dcc695c0 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/mongodb/connectionpool/CustomConnectionPoolTagsProvider.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/mongodb/connectionpool/CustomConnectionPoolTagsProvider.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,7 +21,9 @@ import io.micrometer.core.instrument.Tag import io.micrometer.core.instrument.binder.mongodb.MongoConnectionPoolTagsProvider class CustomConnectionPoolTagsProvider : MongoConnectionPoolTagsProvider { + override fun connectionPoolTags(event: ConnectionPoolCreatedEvent): Iterable { return emptyList() } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/mongodb/connectionpool/MyConnectionPoolTagsProviderConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/mongodb/connectionpool/MyConnectionPoolTagsProviderConfiguration.kt index a3f78493b78..49a40e46da3 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/mongodb/connectionpool/MyConnectionPoolTagsProviderConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/mongodb/connectionpool/MyConnectionPoolTagsProviderConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,8 +22,10 @@ import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) class MyConnectionPoolTagsProviderConfiguration { + @Bean fun customConnectionPoolTagsProvider(): MongoConnectionPoolTagsProvider { return CustomConnectionPoolTagsProvider() } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/all/Address.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/all/Address.kt index a0fd81d657c..8f1e1de11de 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/all/Address.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/all/Address.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.actuator.metrics.supported.timedannotation.all -class Address { -} \ No newline at end of file +class Address \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/all/MyController.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/all/MyController.kt index ea15439a086..b185d77e511 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/all/MyController.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/all/MyController.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.RestController @RestController @Timed class MyController { + @GetMapping("/api/addresses") fun listAddress(): List
? { return /**/null @@ -32,4 +33,5 @@ class MyController { fun listPeople(): List? { return /**/null } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/all/Person.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/all/Person.kt index ec5eb63acc4..c0ba9922049 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/all/Person.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/all/Person.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.actuator.metrics.supported.timedannotation.all -class Person { -} \ No newline at end of file +class Person \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/change/Address.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/change/Address.kt index 81a0d27d348..a05403d2f47 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/change/Address.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/change/Address.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.actuator.metrics.supported.timedannotation.change -class Address { -} \ No newline at end of file +class Address \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/change/MyController.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/change/MyController.kt index 0f96f2e2db9..ca50b9eb02f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/change/MyController.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/change/MyController.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.RestController @RestController @Timed class MyController { + @GetMapping("/api/addresses") fun listAddress(): List
? { return /**/null @@ -33,4 +34,5 @@ class MyController { fun listPeople(): List? { return /**/null } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/change/Person.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/change/Person.kt index 31c1a8dfaaf..1cb805a46a8 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/change/Person.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/change/Person.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.actuator.metrics.supported.timedannotation.change -class Person { -} \ No newline at end of file +class Person \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/single/Address.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/single/Address.kt index d4f33b17a0a..28699eb0b70 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/single/Address.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/single/Address.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.actuator.metrics.supported.timedannotation.single -class Address { -} \ No newline at end of file +class Address \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/single/MyController.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/single/MyController.kt index 9a54609013f..c1dde72c9e4 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/single/MyController.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/single/MyController.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.RestController @RestController class MyController { + @GetMapping("/api/addresses") fun listAddress(): List
? { return /**/null @@ -32,4 +33,5 @@ class MyController { fun listPeople(): List? { return /**/null } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/single/Person.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/single/Person.kt index d8da3871b29..36336ea3ffc 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/single/Person.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/metrics/supported/timedannotation/single/Person.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.actuator.metrics.supported.timedannotation.single -class Person { -} \ No newline at end of file +class Person \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/buildtoolplugins/otherbuildsystems/examplerepackageimplementation/MyBuildTool.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/buildtoolplugins/otherbuildsystems/examplerepackageimplementation/MyBuildTool.kt index 62b6d0bc9a8..cc184961ec8 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/buildtoolplugins/otherbuildsystems/examplerepackageimplementation/MyBuildTool.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/buildtoolplugins/otherbuildsystems/examplerepackageimplementation/MyBuildTool.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -25,6 +25,7 @@ import java.io.IOException import kotlin.jvm.Throws class MyBuildTool { + @Throws(IOException::class) fun build() { val sourceJarFile: File? = /**/null @@ -36,13 +37,14 @@ class MyBuildTool { @Throws(IOException::class) private fun getLibraries(callback: LibraryCallback) { // Build system specific implementation, callback for each dependency - for (nestedJar in compileScopeJars!!) { + for (nestedJar in getCompileScopeJars()!!) { callback.library(Library(nestedJar, LibraryScope.COMPILE)) } // ... } - /**/ - private val compileScopeJars: List? - get() =/**/null + private fun getCompileScopeJars(): List? { + return /**/ null + } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/configurationmetadata/annotationprocessor/automaticmetadatageneration/MyMessagingProperties.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/configurationmetadata/annotationprocessor/automaticmetadatageneration/MyMessagingProperties.kt index 90ea8c33eb0..a87d99e960d 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/configurationmetadata/annotationprocessor/automaticmetadatageneration/MyMessagingProperties.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/configurationmetadata/annotationprocessor/automaticmetadatageneration/MyMessagingProperties.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,11 +17,13 @@ package org.springframework.boot.docs.configurationmetadata.annotationprocessor.automaticmetadatageneration import org.springframework.boot.context.properties.ConfigurationProperties -import java.util.* +import java.util.Arrays @ConfigurationProperties(prefix = "my.messaging") class MyMessagingProperties( + val addresses: List = ArrayList(Arrays.asList("a", "b")), + var containerType: ContainerType = ContainerType.SIMPLE) { enum class ContainerType { diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/configurationmetadata/annotationprocessor/automaticmetadatageneration/MyServerProperties.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/configurationmetadata/annotationprocessor/automaticmetadatageneration/MyServerProperties.kt index 7d0908f701b..11b8cf82b1f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/configurationmetadata/annotationprocessor/automaticmetadatageneration/MyServerProperties.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/configurationmetadata/annotationprocessor/automaticmetadatageneration/MyServerProperties.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -20,16 +20,18 @@ import org.springframework.boot.context.properties.ConfigurationProperties @ConfigurationProperties(prefix = "my.server") class MyServerProperties( + /** * Name of the server. */ var name: String, + /** * IP address to listen to. */ var ip: String = "127.0.0.1", + /** * Port to listen to. */ - var port: Int = 9797) { -} \ No newline at end of file + var port: Int = 9797) \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/configurationmetadata/annotationprocessor/automaticmetadatageneration/nestedproperties/MyServerProperties.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/configurationmetadata/annotationprocessor/automaticmetadatageneration/nestedproperties/MyServerProperties.kt index 37f891402ed..d2119679086 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/configurationmetadata/annotationprocessor/automaticmetadatageneration/nestedproperties/MyServerProperties.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/configurationmetadata/annotationprocessor/automaticmetadatageneration/nestedproperties/MyServerProperties.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,4 +24,5 @@ class MyServerProperties( var host: Host) { class Host(val ip: String, val port: Int = 0) + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/configurationmetadata/format/group/MyProperties.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/configurationmetadata/format/property/MyProperties.kt similarity index 93% rename from spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/configurationmetadata/format/group/MyProperties.kt rename to spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/configurationmetadata/format/property/MyProperties.kt index 69f4f42f471..6e3297b43b5 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/configurationmetadata/format/group/MyProperties.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/configurationmetadata/format/property/MyProperties.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,14 +14,16 @@ * limitations under the License. */ -package org.springframework.boot.docs.configurationmetadata.format.group +package org.springframework.boot.docs.configurationmetadata.format.property import org.springframework.boot.context.properties.ConfigurationProperties import org.springframework.boot.context.properties.DeprecatedConfigurationProperty @ConfigurationProperties("my.app") class MyProperties(val name: String?) { + var target: String? = null @Deprecated("") @DeprecatedConfigurationProperty(replacement = "my.app.name") get @Deprecated("") set + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/configurationmetadata/manualhints/valuehint/MyProperties.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/configurationmetadata/manualhints/valuehint/MyProperties.kt index 58a5ce0451c..8eb8609afff 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/configurationmetadata/manualhints/valuehint/MyProperties.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/configurationmetadata/manualhints/valuehint/MyProperties.kt @@ -1,7 +1,22 @@ +/* + * Copyright 2012-2022 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.boot.docs.configurationmetadata.manualhints.valuehint import org.springframework.boot.context.properties.ConfigurationProperties @ConfigurationProperties("my") -class MyProperties(val contexts: Map) { -} \ No newline at end of file +class MyProperties(val contexts: Map) \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/cassandra/connecting/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/cassandra/connecting/MyBean.kt index a59b498bc22..51bfa19d884 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/cassandra/connecting/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/cassandra/connecting/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,8 +21,11 @@ import org.springframework.stereotype.Component @Component class MyBean(private val template: CassandraTemplate) { + // @fold:on // ... fun someMethod(): Long { return template.count(User::class.java) - } // @fold:off + } + // @fold:off + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/couchbase/repositories/CouchbaseProperties.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/couchbase/repositories/CouchbaseProperties.kt index 15c9938c33c..460b1e5026b 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/couchbase/repositories/CouchbaseProperties.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/couchbase/repositories/CouchbaseProperties.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.data.nosql.couchbase.repositories -class CouchbaseProperties { -} \ No newline at end of file +class CouchbaseProperties \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/couchbase/repositories/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/couchbase/repositories/MyBean.kt index ddb8dc623c1..36c1fec67b9 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/couchbase/repositories/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/couchbase/repositories/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,8 +21,11 @@ import org.springframework.stereotype.Component @Component class MyBean(private val template: CouchbaseTemplate) { + // @fold:on // ... fun someMethod(): String { return template.bucketName - } // @fold:off + } + // @fold:off + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/couchbase/repositories/MyConverter.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/couchbase/repositories/MyConverter.kt index 7397b606c35..f6714bb2bc1 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/couchbase/repositories/MyConverter.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/couchbase/repositories/MyConverter.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -18,9 +18,10 @@ package org.springframework.boot.docs.data.nosql.couchbase.repositories import org.springframework.core.convert.converter.Converter -internal class MyConverter : - Converter { +internal class MyConverter : Converter { + override fun convert(value: CouchbaseProperties?): Boolean { return true } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/couchbase/repositories/MyCouchbaseConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/couchbase/repositories/MyCouchbaseConfiguration.kt index 936a3dbad9b..e2c031d21b1 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/couchbase/repositories/MyCouchbaseConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/couchbase/repositories/MyCouchbaseConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,8 +24,10 @@ import org.springframework.data.couchbase.core.convert.CouchbaseCustomConversion @Configuration(proxyBeanMethods = false) class MyCouchbaseConfiguration { + @Bean(BeanNames.COUCHBASE_CUSTOM_CONVERSIONS) fun myCustomConversions(): CouchbaseCustomConversions { return CouchbaseCustomConversions(Arrays.asList(MyConverter())) } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/elasticsearch/connectingusingspringdata/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/elasticsearch/connectingusingspringdata/MyBean.kt index 84704dd29d6..8b8f95888eb 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/elasticsearch/connectingusingspringdata/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/elasticsearch/connectingusingspringdata/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,8 +21,11 @@ import org.springframework.stereotype.Component @Component class MyBean(private val template: ElasticsearchRestTemplate) { + // @fold:on // ... fun someMethod(id: String): Boolean { return template.exists(id, User::class.java) - } // @fold:off + } + // @fold:off + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/elasticsearch/connectingusingspringdata/User.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/elasticsearch/connectingusingspringdata/User.kt index 04d6cf5c848..69bd871dec8 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/elasticsearch/connectingusingspringdata/User.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/elasticsearch/connectingusingspringdata/User.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.data.nosql.elasticsearch.connectingusingspringdata -class User { -} \ No newline at end of file +class User \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/ldap/repositories/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/ldap/repositories/MyBean.kt index 77700089305..dd6928eee5c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/ldap/repositories/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/ldap/repositories/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,8 +21,11 @@ import org.springframework.stereotype.Component @Component class MyBean(private val template: LdapTemplate) { + // @fold:on // ... fun someMethod(): List { return template.findAll(User::class.java) - } // @fold:off + } + // @fold:off + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/ldap/repositories/User.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/ldap/repositories/User.kt index ab2c823261d..dea5398c5c7 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/ldap/repositories/User.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/ldap/repositories/User.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.data.nosql.ldap.repositories -class User { -} \ No newline at end of file +class User \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/mongodb/connecting/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/mongodb/connecting/MyBean.kt index 6cf718f49c1..e22d2fac0c3 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/mongodb/connecting/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/mongodb/connecting/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,9 +23,12 @@ import org.springframework.stereotype.Component @Component class MyBean(private val mongo: MongoDatabaseFactory) { + // @fold:on // ... fun someMethod(): MongoCollection { val db = mongo.mongoDatabase return db.getCollection("users") - } // @fold:off + } + // @fold:off + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/mongodb/repositories/City.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/mongodb/repositories/City.kt index 5cc7d765d26..56b09979bca 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/mongodb/repositories/City.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/mongodb/repositories/City.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.data.nosql.mongodb.repositories -class City { -} \ No newline at end of file +class City \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/mongodb/repositories/CityRepository.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/mongodb/repositories/CityRepository.kt index 247c4088de2..537b7339998 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/mongodb/repositories/CityRepository.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/mongodb/repositories/CityRepository.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/mongodb/template/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/mongodb/template/MyBean.kt index 06ce2973b42..2e41706145e 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/mongodb/template/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/mongodb/template/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,8 +23,11 @@ import org.springframework.stereotype.Component @Component class MyBean(private val mongoTemplate: MongoTemplate) { + // @fold:on // ... fun someMethod(): MongoCollection { return mongoTemplate.getCollection("users") - } // @fold:off + } + // @fold:off + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/neo4j/connecting/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/neo4j/connecting/MyBean.kt index ac897c6dcc1..08cc2311cea 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/neo4j/connecting/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/neo4j/connecting/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -26,14 +26,13 @@ class MyBean(private val driver: Driver) { // @fold:on // ... fun someMethod(message: String?): String { driver.session().use { session -> - return session.writeTransaction { transaction: Transaction -> - transaction - .run( - "CREATE (a:Greeting) SET a.message = \$message RETURN a.message + ', from node ' + id(a)", - Values.parameters("message", message) - ) - .single()[0].asString() + return@someMethod session.writeTransaction { transaction: Transaction -> + transaction.run( + "CREATE (a:Greeting) SET a.message = \$message RETURN a.message + ', from node ' + id(a)", + Values.parameters("message", message) + ).single()[0].asString() } } - } // @fold:off + } + // @fold:off } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/neo4j/repositories/City.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/neo4j/repositories/City.kt index ae8ff006691..50c0329d4ca 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/neo4j/repositories/City.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/neo4j/repositories/City.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.data.nosql.neo4j.repositories -class City { -} \ No newline at end of file +class City \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/neo4j/repositories/CityRepository.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/neo4j/repositories/CityRepository.kt index 32cfb0cdba1..a2a6a645eea 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/neo4j/repositories/CityRepository.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/neo4j/repositories/CityRepository.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,9 +17,10 @@ package org.springframework.boot.docs.data.nosql.neo4j.repositories import org.springframework.data.neo4j.repository.Neo4jRepository -import java.util.* +import java.util.Optional + +interface CityRepository : Neo4jRepository { -interface CityRepository : - Neo4jRepository { fun findOneByNameAndState(name: String?, state: String?): Optional? + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/neo4j/repositories/MyNeo4jConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/neo4j/repositories/MyNeo4jConfiguration.kt index 88c039b6d7d..ae0eccfd850 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/neo4j/repositories/MyNeo4jConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/neo4j/repositories/MyNeo4jConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,11 +24,10 @@ import org.springframework.data.neo4j.core.transaction.ReactiveNeo4jTransactionM @Configuration(proxyBeanMethods = false) class MyNeo4jConfiguration { + @Bean - fun reactiveTransactionManager( - driver: Driver, - databaseNameProvider: ReactiveDatabaseSelectionProvider - ): ReactiveNeo4jTransactionManager { + fun reactiveTransactionManager(driver: Driver, + databaseNameProvider: ReactiveDatabaseSelectionProvider): ReactiveNeo4jTransactionManager { return ReactiveNeo4jTransactionManager(driver, databaseNameProvider) } } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/redis/connecting/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/redis/connecting/MyBean.kt index 762b6917c89..10c5ad1af4c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/redis/connecting/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/redis/connecting/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,8 +21,11 @@ import org.springframework.stereotype.Component @Component class MyBean(private val template: StringRedisTemplate) { + // @fold:on // ... fun someMethod(): Boolean { return template.hasKey("spring") - } // @fold:off + } + // @fold:off + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/solr/connecting/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/solr/connecting/MyBean.kt index 438cd3dbbee..12ff0a3ae40 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/solr/connecting/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/solr/connecting/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -20,11 +20,13 @@ import org.apache.solr.client.solrj.SolrClient import org.apache.solr.client.solrj.response.SolrPingResponse import org.springframework.stereotype.Component - @Component class MyBean(private val solr: SolrClient) { + // @fold:on // ... fun someMethod(): SolrPingResponse { return solr.ping("users") - } // @fold:off + } + // @fold:off + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jdbctemplate/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jdbctemplate/MyBean.kt index 8ec0df5aa14..e66f4fa114a 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jdbctemplate/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jdbctemplate/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,7 +21,9 @@ import org.springframework.stereotype.Component @Component class MyBean(private val jdbcTemplate: JdbcTemplate) { + fun doSomething() { jdbcTemplate.execute("delete from customer") } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jooq/dslcontext/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jooq/dslcontext/MyBean.kt index 4ce3bf80550..68b8a699704 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jooq/dslcontext/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jooq/dslcontext/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -18,16 +18,17 @@ package org.springframework.boot.docs.data.sql.jooq.dslcontext import org.jooq.DSLContext import org.springframework.stereotype.Component -import java.util.* +import java.util.GregorianCalendar @Component class MyBean(private val create: DSLContext) { + // tag::method[] fun authorsBornAfter1980(): List { - // @formatter:off return create.selectFrom(Tables.AUTHOR) .where(Tables.AUTHOR?.DATE_OF_BIRTH?.greaterThan(GregorianCalendar(1980, 0, 1))) .fetch(Tables.AUTHOR?.DATE_OF_BIRTH) - // @formatter:on - } // end::method[] + } + // end::method[] + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jooq/dslcontext/Tables.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jooq/dslcontext/Tables.kt index 997c8145b31..fe7a924365f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jooq/dslcontext/Tables.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jooq/dslcontext/Tables.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,15 +21,16 @@ import org.jooq.Table import org.jooq.TableField import org.jooq.impl.TableImpl import org.jooq.impl.TableRecordImpl -import java.util.* +import java.util.GregorianCalendar object Tables { + val AUTHOR: TAuthor? = null abstract class TAuthor(name: Name?) : TableImpl(name) { val DATE_OF_BIRTH: TableField? = null } - abstract class TAuthorRecord(table: Table?) : - TableRecordImpl(table) + abstract class TAuthorRecord(table: Table?) : TableRecordImpl(table) + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jpaandspringdata/entityclasses/City.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jpaandspringdata/entityclasses/City.kt index a482c6ff774..7fa7c9c72b3 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jpaandspringdata/entityclasses/City.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jpaandspringdata/entityclasses/City.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,6 +24,7 @@ import javax.persistence.Id @Entity class City : Serializable { + @Id @GeneratedValue private val id: Long? = null @@ -48,4 +49,5 @@ class City : Serializable { this.name = name this.state = state } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jpaandspringdata/entityclasses/Country.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jpaandspringdata/entityclasses/Country.kt index 123427d8d5a..eb40363e688 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jpaandspringdata/entityclasses/Country.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jpaandspringdata/entityclasses/Country.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -25,6 +25,7 @@ import javax.persistence.Id @Entity class Country : Serializable { + @Id @GeneratedValue var id: Long? = null @@ -32,4 +33,5 @@ class Country : Serializable { @Audited @Column(nullable = false) var name: String? = null + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jpaandspringdata/repositories/CountryRepository.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jpaandspringdata/enversrepositories/CountryRepository.kt similarity index 86% rename from spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jpaandspringdata/repositories/CountryRepository.kt rename to spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jpaandspringdata/enversrepositories/CountryRepository.kt index ad77878638d..3a3e69a8562 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jpaandspringdata/repositories/CountryRepository.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jpaandspringdata/enversrepositories/CountryRepository.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.data.sql.jpaandspringdata.repositories +package org.springframework.boot.docs.data.sql.jpaandspringdata.enversrepositories import org.springframework.boot.docs.data.sql.jpaandspringdata.entityclasses.Country import org.springframework.data.domain.Page @@ -23,7 +23,9 @@ import org.springframework.data.repository.Repository import org.springframework.data.repository.history.RevisionRepository interface CountryRepository : - RevisionRepository, - Repository { + RevisionRepository, + Repository { + fun findAll(pageable: Pageable?): Page? + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jpaandspringdata/repositories/CityRepository.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jpaandspringdata/repositories/CityRepository.kt index 316ec6bf272..a247e5f000c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jpaandspringdata/repositories/CityRepository.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/jpaandspringdata/repositories/CityRepository.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,8 +21,10 @@ import org.springframework.data.domain.Page import org.springframework.data.domain.Pageable import org.springframework.data.repository.Repository -interface CityRepository : - Repository { +interface CityRepository : Repository { + fun findAll(pageable: Pageable?): Page? + fun findByNameAndStateAllIgnoringCase(name: String?, state: String?): City? + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/r2dbc/MyPostgresR2dbcConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/r2dbc/MyPostgresR2dbcConfiguration.kt index 37f4994a81b..6fac519e108 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/r2dbc/MyPostgresR2dbcConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/r2dbc/MyPostgresR2dbcConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,23 +17,21 @@ package org.springframework.boot.docs.data.sql.r2dbc import io.r2dbc.postgresql.PostgresqlConnectionFactoryProvider -import io.r2dbc.spi.ConnectionFactoryOptions import org.springframework.boot.autoconfigure.r2dbc.ConnectionFactoryOptionsBuilderCustomizer import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) class MyPostgresR2dbcConfiguration { + @Bean fun postgresCustomizer(): ConnectionFactoryOptionsBuilderCustomizer { val options: MutableMap = HashMap() options["lock_timeout"] = "30s" options["statement_timeout"] = "60s" - return ConnectionFactoryOptionsBuilderCustomizer { builder: ConnectionFactoryOptions.Builder -> - builder.option( - PostgresqlConnectionFactoryProvider.OPTIONS, - options - ) + return ConnectionFactoryOptionsBuilderCustomizer { builder -> + builder.option(PostgresqlConnectionFactoryProvider.OPTIONS, options) } } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/r2dbc/MyR2dbcConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/r2dbc/MyR2dbcConfiguration.kt index 19da4126349..f1cef3e4694 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/r2dbc/MyR2dbcConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/r2dbc/MyR2dbcConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,13 +23,12 @@ import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) class MyR2dbcConfiguration { + @Bean fun connectionFactoryPortCustomizer(): ConnectionFactoryOptionsBuilderCustomizer { - return ConnectionFactoryOptionsBuilderCustomizer { builder: ConnectionFactoryOptions.Builder -> - builder.option( - ConnectionFactoryOptions.PORT, - 5432 - ) + return ConnectionFactoryOptionsBuilderCustomizer { builder -> + builder.option(ConnectionFactoryOptions.PORT, 5432) } } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/r2dbc/repositories/City.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/r2dbc/repositories/City.kt index 3d05509daca..4134eaa2d05 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/r2dbc/repositories/City.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/r2dbc/repositories/City.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.data.sql.r2dbc.repositories -class City { -} \ No newline at end of file +class City \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/r2dbc/repositories/CityRepository.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/r2dbc/repositories/CityRepository.kt index 0401d9efb2c..2454ae7c2d3 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/r2dbc/repositories/CityRepository.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/r2dbc/repositories/CityRepository.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -19,7 +19,8 @@ package org.springframework.boot.docs.data.sql.r2dbc.repositories import org.springframework.data.repository.Repository import reactor.core.publisher.Mono -interface CityRepository : - Repository { +interface CityRepository : Repository { + fun findByNameAndStateAllIgnoringCase(name: String?, state: String?): Mono? + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/r2dbc/usingdatabaseclient/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/r2dbc/usingdatabaseclient/MyBean.kt index cf444c5432e..8e8ca16f220 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/r2dbc/usingdatabaseclient/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/sql/r2dbc/usingdatabaseclient/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,8 +22,11 @@ import reactor.core.publisher.Flux @Component class MyBean(private val databaseClient: DatabaseClient) { + // @fold:on // ... fun someMethod(): Flux> { return databaseClient.sql("select * from user").fetch().all() - } // @fold:off + } + // @fold:off + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/deployment/cloud/cloudfoundry/bindingtoservices/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/deployment/cloud/cloudfoundry/bindingtoservices/MyBean.kt index 7e7527312ce..0399da6b794 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/deployment/cloud/cloudfoundry/bindingtoservices/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/deployment/cloud/cloudfoundry/bindingtoservices/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,10 +22,13 @@ import org.springframework.stereotype.Component @Component class MyBean : EnvironmentAware { + private var instanceId: String? = null + override fun setEnvironment(environment: Environment) { instanceId = environment.getProperty("vcap.application.instance_id") } // ... + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/devtools/restart/disable/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/devtools/restart/disable/MyApplication.kt index c7611857be9..ba505d49565 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/devtools/restart/disable/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/devtools/restart/disable/MyApplication.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/conditionannotations/beanconditions/MyAutoConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/conditionannotations/beanconditions/MyAutoConfiguration.kt index 4e4d4088478..2108ffcd707 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/conditionannotations/beanconditions/MyAutoConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/conditionannotations/beanconditions/MyAutoConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,9 +22,11 @@ import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) class MyAutoConfiguration { + @Bean @ConditionalOnMissingBean fun someService(): SomeService { return SomeService() } + } diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/conditionannotations/beanconditions/SomeService.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/conditionannotations/beanconditions/SomeService.kt index 85533ea9b0b..95fa05f6a72 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/conditionannotations/beanconditions/SomeService.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/conditionannotations/beanconditions/SomeService.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/conditionannotations/classconditions/MyAutoConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/conditionannotations/classconditions/MyAutoConfiguration.kt index 590de6f1e44..8e452b1a441 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/conditionannotations/classconditions/MyAutoConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/conditionannotations/classconditions/MyAutoConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,14 +24,18 @@ import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) // Some conditions ... class MyAutoConfiguration { + // Auto-configured beans ... @Configuration(proxyBeanMethods = false) @ConditionalOnClass(SomeService::class) class SomeServiceConfiguration { + @Bean @ConditionalOnMissingBean fun someService(): SomeService { return SomeService() } + } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/conditionannotations/classconditions/SomeService.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/conditionannotations/classconditions/SomeService.kt index 5bfb6fdf3d0..e83096ff78f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/conditionannotations/classconditions/SomeService.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/conditionannotations/classconditions/SomeService.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/customstarter/configurationkeys/AcmeProperties.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/customstarter/configurationkeys/AcmeProperties.kt index fecd533bd0d..74d9f77b7f2 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/customstarter/configurationkeys/AcmeProperties.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/customstarter/configurationkeys/AcmeProperties.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,6 +21,7 @@ import java.time.Duration @ConfigurationProperties("acme") class AcmeProperties( + /** * Whether to check the location of acme resources. */ diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/testing/MyConditionEvaluationReportingTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/testing/MyConditionEvaluationReportingTests.kt index b88a83f6f76..9e5d729cec4 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/testing/MyConditionEvaluationReportingTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/testing/MyConditionEvaluationReportingTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,13 +22,14 @@ import org.springframework.boot.logging.LogLevel import org.springframework.boot.test.context.assertj.AssertableApplicationContext import org.springframework.boot.test.context.runner.ApplicationContextRunner +@Suppress("UNUSED_ANONYMOUS_PARAMETER") class MyConditionEvaluationReportingTests { + @Test fun autoConfigTest() { - // @formatter:off ApplicationContextRunner() .withInitializer(ConditionEvaluationReportLoggingListener(LogLevel.INFO)) .run { context: AssertableApplicationContext? -> } - // @formatter:on } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/testing/MyService.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/testing/MyService.kt index 499ce02ce9a..ad7a77a6e36 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/testing/MyService.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/testing/MyService.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/testing/MyServiceAutoConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/testing/MyServiceAutoConfiguration.kt index 883a5a93490..85ed2606097 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/testing/MyServiceAutoConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/testing/MyServiceAutoConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -30,6 +30,7 @@ import org.springframework.context.annotation.Configuration UserProperties::class ) class MyServiceAutoConfiguration { + @Bean @ConditionalOnMissingBean fun userService(properties: UserProperties): MyService { @@ -40,4 +41,5 @@ class MyServiceAutoConfiguration { class UserProperties { var name = "test" } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/testing/MyServiceAutoConfigurationTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/testing/MyServiceAutoConfigurationTests.kt index f47efcc43a3..7c917d3b4b0 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/testing/MyServiceAutoConfigurationTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/developingautoconfiguration/testing/MyServiceAutoConfigurationTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,7 +16,7 @@ package org.springframework.boot.docs.features.developingautoconfiguration.testing -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.boot.autoconfigure.AutoConfigurations import org.springframework.boot.test.context.FilteredClassLoader @@ -25,67 +25,53 @@ import org.springframework.boot.test.context.runner.ApplicationContextRunner import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration - internal open class MyServiceAutoConfigurationTests { + // tag::runner[] val contextRunner = ApplicationContextRunner() .withConfiguration(AutoConfigurations.of(MyServiceAutoConfiguration::class.java)) // end::runner[] + // tag::test-env[] @Test fun serviceNameCanBeConfigured() { contextRunner.withPropertyValues("user.name=test123").run { context: AssertableApplicationContext -> - Assertions.assertThat(context) - .hasSingleBean( - MyService::class.java - ) - Assertions.assertThat( - context.getBean( - MyService::class.java - ).name - ).isEqualTo("test123") + assertThat(context).hasSingleBean(MyService::class.java) + assertThat(context.getBean(MyService::class.java).name).isEqualTo("test123") } } - // end::test-env[] + // tag::test-classloader[] @Test fun serviceIsIgnoredIfLibraryIsNotPresent() { contextRunner.withClassLoader(FilteredClassLoader(MyService::class.java)) .run { context: AssertableApplicationContext? -> - Assertions.assertThat( - context - ).doesNotHaveBean("myService") + assertThat(context).doesNotHaveBean("myService") } } - // end::test-classloader[] + // tag::test-user-config[] @Test fun defaultServiceBacksOff() { contextRunner.withUserConfiguration(UserConfiguration::class.java) .run { context: AssertableApplicationContext -> - Assertions.assertThat( - context - ).hasSingleBean( - MyService::class.java - ) - Assertions.assertThat( - context - ).getBean("myCustomService").isSameAs( - context.getBean( - MyService::class.java - ) - ) + assertThat(context).hasSingleBean(MyService::class.java) + assertThat(context).getBean("myCustomService") + .isSameAs(context.getBean(MyService::class.java)) } } @Configuration(proxyBeanMethods = false) internal class UserConfiguration { + @Bean fun myCustomService(): MyService { return MyService("mine") } - } // end::test-user-config[] + + } + // end::test-user-config[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/MyBean.kt index 81fb4d8631a..246ebd26d7f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,8 +21,10 @@ import org.springframework.stereotype.Component @Component class MyBean { + @Value("\${name}") private val name: String? = null // ... + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/constructorbinding/MyProperties.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/constructorbinding/MyProperties.kt index 66770114ac7..1780de451b2 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/constructorbinding/MyProperties.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/constructorbinding/MyProperties.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,10 +23,10 @@ import java.net.InetAddress @ConstructorBinding @ConfigurationProperties("my.service") -class MyProperties(val enabled: Boolean, val remoteAddress: InetAddress, val security: Security) { +class MyProperties(val enabled: Boolean, val remoteAddress: InetAddress, + val security: Security) { + + class Security(val username: String, val password: String, + @param:DefaultValue("USER") val roles: List) - class Security( - val username: String, val password: String, - @param:DefaultValue("USER") val roles: List - ) } diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/constructorbinding/nonnull/MyProperties.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/constructorbinding/nonnull/MyProperties.kt index 84034212b44..806cc3125ec 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/constructorbinding/nonnull/MyProperties.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/constructorbinding/nonnull/MyProperties.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,12 +23,10 @@ import java.net.InetAddress @ConstructorBinding @ConfigurationProperties("my.service") -class MyProperties( - val isEnabled: Boolean, val remoteAddress: InetAddress, @param:DefaultValue val security: Security -) { +class MyProperties(val isEnabled: Boolean, val remoteAddress: InetAddress, + @param:DefaultValue val security: Security) { + + class Security(val username: String, val password: String, + @param:DefaultValue("USER") val roles: List) - class Security( - val username: String, val password: String, - @param:DefaultValue("USER") val roles: List - ) } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/conversion/datasizes/constructorbinding/MyProperties.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/conversion/datasizes/constructorbinding/MyProperties.kt index 26e66b94bad..f62864fc0fb 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/conversion/datasizes/constructorbinding/MyProperties.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/conversion/datasizes/constructorbinding/MyProperties.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -25,8 +25,5 @@ import org.springframework.util.unit.DataUnit @ConfigurationProperties("my") @ConstructorBinding -class MyProperties( - @param:DataSizeUnit(DataUnit.MEGABYTES) @param:DefaultValue("2MB") - val bufferSize: DataSize, - @param:DefaultValue("512B") val sizeThreshold: DataSize -) \ No newline at end of file +class MyProperties(@param:DataSizeUnit(DataUnit.MEGABYTES) @param:DefaultValue("2MB") val bufferSize: DataSize, + @param:DefaultValue("512B") val sizeThreshold: DataSize) diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/conversion/datasizes/javabeanbinding/MyProperties.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/conversion/datasizes/javabeanbinding/MyProperties.kt index 27601046439..ed99d721455 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/conversion/datasizes/javabeanbinding/MyProperties.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/conversion/datasizes/javabeanbinding/MyProperties.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,8 +23,10 @@ import org.springframework.util.unit.DataUnit @ConfigurationProperties("my") class MyProperties { + @DataSizeUnit(DataUnit.MEGABYTES) var bufferSize = DataSize.ofMegabytes(2) var sizeThreshold = DataSize.ofBytes(512) + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/conversion/durations/constructorbinding/MyProperties.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/conversion/durations/constructorbinding/MyProperties.kt index 4101c0dcd66..18832fee14c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/conversion/durations/constructorbinding/MyProperties.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/conversion/durations/constructorbinding/MyProperties.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -25,7 +25,5 @@ import java.time.temporal.ChronoUnit @ConfigurationProperties("my") @ConstructorBinding -class MyProperties( - @param:DurationUnit(ChronoUnit.SECONDS) @param:DefaultValue("30s") val sessionTimeout: Duration, - @param:DefaultValue("1000ms") val readTimeout: Duration -) +class MyProperties(@param:DurationUnit(ChronoUnit.SECONDS) @param:DefaultValue("30s") val sessionTimeout: Duration, + @param:DefaultValue("1000ms") val readTimeout: Duration) diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/conversion/durations/javabeanbinding/MyProperties.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/conversion/durations/javabeanbinding/MyProperties.kt index ba192add4d1..d05158cd9c5 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/conversion/durations/javabeanbinding/MyProperties.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/conversion/durations/javabeanbinding/MyProperties.kt @@ -1,3 +1,19 @@ +/* + * Copyright 2012-2022 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.boot.docs.features.externalconfig.typesafeconfigurationproperties.conversion.durations.javabeanbinding import org.springframework.boot.context.properties.ConfigurationProperties @@ -7,8 +23,10 @@ import java.time.temporal.ChronoUnit @ConfigurationProperties("my") class MyProperties { + @DurationUnit(ChronoUnit.SECONDS) var sessionTimeout = Duration.ofSeconds(30) var readTimeout = Duration.ofMillis(1000) + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/enablingannotatedtypes/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/enablingannotatedtypes/MyApplication.kt index 854c0659fae..7b28eed2c95 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/enablingannotatedtypes/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/enablingannotatedtypes/MyApplication.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,4 +21,4 @@ import org.springframework.boot.context.properties.ConfigurationPropertiesScan @SpringBootApplication @ConfigurationPropertiesScan("com.example.app", "com.example.another") -class MyApplication \ No newline at end of file +class MyApplication diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/enablingannotatedtypes/MyConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/enablingannotatedtypes/MyConfiguration.kt index 1cd0ac643ad..d944fd77057 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/enablingannotatedtypes/MyConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/enablingannotatedtypes/MyConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,4 +21,4 @@ import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) @EnableConfigurationProperties(SomeProperties::class) -class MyConfiguration \ No newline at end of file +class MyConfiguration diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/javabeanbinding/MyProperties.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/javabeanbinding/MyProperties.kt index e4bada2ad7a..78292311075 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/javabeanbinding/MyProperties.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/javabeanbinding/MyProperties.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,14 +21,21 @@ import java.net.InetAddress @ConfigurationProperties("my.service") class MyProperties { + var isEnabled = false + var remoteAddress: InetAddress? = null + val security = Security() class Security { + var username: String? = null + var password: String? = null var roles: List = ArrayList(setOf("USER")) + } + } diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/mergingcomplextypes/list/MyPojo.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/mergingcomplextypes/list/MyPojo.kt index 24e6070c664..4a92d41b4ff 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/mergingcomplextypes/list/MyPojo.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/mergingcomplextypes/list/MyPojo.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.features.externalconfig.typesafeconfigurationproperties.mergingcomplextypes.list -class MyPojo { -} \ No newline at end of file +class MyPojo \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/mergingcomplextypes/list/MyProperties.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/mergingcomplextypes/list/MyProperties.kt index 0f954eba543..aaf273b66d9 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/mergingcomplextypes/list/MyProperties.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/mergingcomplextypes/list/MyProperties.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -20,5 +20,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties @ConfigurationProperties("my") class MyProperties { + val list: List = ArrayList() + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/mergingcomplextypes/map/MyPojo.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/mergingcomplextypes/map/MyPojo.kt index 38bd0185fa5..28fcfd171a2 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/mergingcomplextypes/map/MyPojo.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/mergingcomplextypes/map/MyPojo.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.features.externalconfig.typesafeconfigurationproperties.mergingcomplextypes.map -class MyPojo { -} \ No newline at end of file +class MyPojo \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/mergingcomplextypes/map/MyProperties.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/mergingcomplextypes/map/MyProperties.kt index 43764ba3b62..5bebf61b2a8 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/mergingcomplextypes/map/MyProperties.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/mergingcomplextypes/map/MyProperties.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -20,5 +20,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties @ConfigurationProperties("my") class MyProperties { + val map: Map = LinkedHashMap() + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/relaxedbinding/MyPersonProperties.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/relaxedbinding/MyPersonProperties.kt index 6946b4512f3..6be11c0365f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/relaxedbinding/MyPersonProperties.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/relaxedbinding/MyPersonProperties.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -20,5 +20,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties @ConfigurationProperties(prefix = "my.main-project.person") class MyPersonProperties { + var firstName: String? = null + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/thirdpartyconfiguration/AnotherComponent.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/thirdpartyconfiguration/AnotherComponent.kt index 9066e0859ff..1ecae2e61b6 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/thirdpartyconfiguration/AnotherComponent.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/thirdpartyconfiguration/AnotherComponent.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.features.externalconfig.typesafeconfigurationproperties.thirdpartyconfiguration -class AnotherComponent { -} \ No newline at end of file +class AnotherComponent \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/thirdpartyconfiguration/ThirdPartyConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/thirdpartyconfiguration/ThirdPartyConfiguration.kt index 78ce041f17e..ae4039cd62c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/thirdpartyconfiguration/ThirdPartyConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/thirdpartyconfiguration/ThirdPartyConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,7 +22,9 @@ import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) class ThirdPartyConfiguration { + @Bean @ConfigurationProperties(prefix = "another") fun anotherComponent(): AnotherComponent = AnotherComponent() -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/usingannotatedtypes/MyService.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/usingannotatedtypes/MyService.kt index 5b899f009fd..38003e6def0 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/usingannotatedtypes/MyService.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/usingannotatedtypes/MyService.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -20,6 +20,7 @@ import org.springframework.stereotype.Service @Service class MyService(val properties: SomeProperties) { + fun openConnection() { val server = Server(properties.remoteAddress) server.start() @@ -27,4 +28,5 @@ class MyService(val properties: SomeProperties) { } // ... + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/usingannotatedtypes/SomeProperties.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/usingannotatedtypes/SomeProperties.kt index ae6adbd0499..932b9c0ea05 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/usingannotatedtypes/SomeProperties.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/usingannotatedtypes/SomeProperties.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -13,9 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.boot.docs.features.externalconfig.typesafeconfigurationproperties.usingannotatedtypes class SomeProperties { + val remoteAddress: Any? get() = null + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/validate/MyProperties.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/validate/MyProperties.kt index ca2b3b66f12..633d71313f3 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/validate/MyProperties.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/validate/MyProperties.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,5 +24,7 @@ import javax.validation.constraints.NotNull @ConfigurationProperties("my.service") @Validated class MyProperties { + var remoteAddress: @NotNull InetAddress? = null + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/validate/nested/MyProperties.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/validate/nested/MyProperties.kt index 03ec249b949..493e77f6239 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/validate/nested/MyProperties.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/validate/nested/MyProperties.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -26,10 +26,13 @@ import javax.validation.constraints.NotNull @ConfigurationProperties("my.service") @Validated class MyProperties { + var remoteAddress: @NotNull InetAddress? = null + val security: @Valid Security? = Security() class Security { var username: @NotEmpty String? = null } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/validation/MyProperties.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/validation/MyProperties.kt new file mode 100644 index 00000000000..dc22bd0aea5 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/validation/MyProperties.kt @@ -0,0 +1,30 @@ +/* + * Copyright 2012-2022 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.features.externalconfig.typesafeconfigurationproperties.validation + +import org.springframework.boot.context.properties.ConfigurationProperties +import org.springframework.validation.annotation.Validated +import java.net.InetAddress +import javax.validation.constraints.NotNull + +@ConfigurationProperties("my.service") +@Validated +class MyProperties { + + var remoteAddress: @NotNull InetAddress? = null + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/validation/nested/MyProperties.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/validation/nested/MyProperties.kt new file mode 100644 index 00000000000..cd909159399 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/validation/nested/MyProperties.kt @@ -0,0 +1,42 @@ +/* + * Copyright 2012-2022 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.features.externalconfig.typesafeconfigurationproperties.validation.nested + +import org.springframework.boot.context.properties.ConfigurationProperties +import org.springframework.validation.annotation.Validated +import java.net.InetAddress +import javax.validation.Valid +import javax.validation.constraints.NotEmpty +import javax.validation.constraints.NotNull + +@ConfigurationProperties("my.service") +@Validated +class MyProperties { + + var remoteAddress: @NotNull InetAddress? = null + + @Valid + val security = Security() + + class Security { + + @NotEmpty + var username: String? = null + + } + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/profiles/ProductionConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/profiles/ProductionConfiguration.kt index 2d053d12dbb..927b40b2653 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/profiles/ProductionConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/profiles/ProductionConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/MyApplication.kt index 5db9c3513d6..2ec0c57dc67 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/MyApplication.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -25,4 +25,4 @@ class MyApplication fun main(args: Array) { SpringApplication.run(MyApplication::class.java, *args) -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationarguments/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationarguments/MyBean.kt index adf04829357..aa430a99509 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationarguments/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationarguments/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,6 +21,7 @@ import org.springframework.stereotype.Component @Component class MyBean(args: ApplicationArguments) { + init { val debug = args.containsOption("debug") val files = args.nonOptionArgs @@ -29,4 +30,5 @@ class MyBean(args: ApplicationArguments) { } // if run with "--debug logfile.txt" prints ["logfile.txt"] } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationavailability/managing/MyLocalCacheVerifier.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationavailability/managing/MyLocalCacheVerifier.kt index 67f59e3cf10..a57b53b57a4 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationavailability/managing/MyLocalCacheVerifier.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationavailability/managing/MyLocalCacheVerifier.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,6 +23,7 @@ import org.springframework.stereotype.Component @Component class MyLocalCacheVerifier(private val eventPublisher: ApplicationEventPublisher) { + fun checkLocalCache() { try { // ... @@ -30,4 +31,5 @@ class MyLocalCacheVerifier(private val eventPublisher: ApplicationEventPublisher AvailabilityChangeEvent.publish(eventPublisher, ex, LivenessState.BROKEN) } } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationavailability/managing/MyReadinessStateExporter.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationavailability/managing/MyReadinessStateExporter.kt index ed273c16f04..ff6080f0dcc 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationavailability/managing/MyReadinessStateExporter.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationavailability/managing/MyReadinessStateExporter.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -38,4 +38,5 @@ class MyReadinessStateExporter { } } } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationexit/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationexit/MyApplication.kt index 44c0c8b813e..8a9af9e30af 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationexit/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/applicationexit/MyApplication.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,10 +23,12 @@ import org.springframework.context.annotation.Bean @SpringBootApplication class MyApplication { + @Bean fun exitCodeGenerator(): ExitCodeGenerator? { return ExitCodeGenerator { 42 } } + } fun main(args: Array) { diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/commandlinerunner/MyCommandLineRunner.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/commandlinerunner/MyCommandLineRunner.kt index 93bab420db1..3c65b842cbe 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/commandlinerunner/MyCommandLineRunner.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/commandlinerunner/MyCommandLineRunner.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,7 +21,9 @@ import org.springframework.stereotype.Component @Component class MyCommandLineRunner : CommandLineRunner { + override fun run(vararg args: String) { // Do something... } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/customizingspringapplication/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/customizingspringapplication/MyApplication.kt index f9b974d1a93..4afc48f5115 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/customizingspringapplication/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/customizingspringapplication/MyApplication.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -19,7 +19,6 @@ package org.springframework.boot.docs.features.springapplication.customizingspri import org.springframework.boot.Banner import org.springframework.boot.SpringApplication import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.runApplication @SpringBootApplication class MyApplication diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/fluentbuilderapi/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/fluentbuilderapi/MyApplication.kt index dfa1df50330..fbbb1338a00 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/fluentbuilderapi/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/fluentbuilderapi/MyApplication.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,7 +21,6 @@ import org.springframework.boot.builder.SpringApplicationBuilder class MyApplication { fun hierarchyWithDisabledBanner(args: Array) { - // @formatter:off // tag::code[] SpringApplicationBuilder() .sources(Parent::class.java) @@ -29,9 +28,10 @@ class MyApplication { .bannerMode(Banner.Mode.OFF) .run(*args) // end::code[] - // @formatter:on } internal class Parent + internal class Application + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/startuptracking/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/startuptracking/MyApplication.kt index 7e998fc99ae..85a2b1c630a 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/startuptracking/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/springapplication/startuptracking/MyApplication.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/additionalautoconfigurationandslicing/MyJdbcTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/additionalautoconfigurationandslicing/MyJdbcTests.kt index ab5862b7ce4..18b31d60388 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/additionalautoconfigurationandslicing/MyJdbcTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/additionalautoconfigurationandslicing/MyJdbcTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,6 +22,4 @@ import org.springframework.boot.test.autoconfigure.jdbc.JdbcTest @JdbcTest @ImportAutoConfiguration(IntegrationAutoConfiguration::class) -class MyJdbcTests { - -} \ No newline at end of file +class MyJdbcTests diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredjdbc/MyTransactionalTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredjdbc/MyTransactionalTests.kt index 4468af79fa3..9ccab1796f9 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredjdbc/MyTransactionalTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredjdbc/MyTransactionalTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,4 +22,4 @@ import org.springframework.transaction.annotation.Transactional @JdbcTest @Transactional(propagation = Propagation.NOT_SUPPORTED) -class MyTransactionalTests \ No newline at end of file +class MyTransactionalTests diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredjooq/MyJooqTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredjooq/MyJooqTests.kt index 086e440f79e..62a39624c12 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredjooq/MyJooqTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredjooq/MyJooqTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -25,4 +25,4 @@ class MyJooqTests(@Autowired val dslContext: DSLContext) { // ... -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredrestclient/MyRestClientTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredrestclient/MyRestClientTests.kt index a3b88ef5b81..3345aa56170 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredrestclient/MyRestClientTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredrestclient/MyRestClientTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,7 +16,7 @@ package org.springframework.boot.docs.features.testing.springbootapplications.autoconfiguredrestclient -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.web.client.RestClientTest @@ -35,6 +35,7 @@ class MyRestClientTests( server.expect(MockRestRequestMatchers.requestTo("/greet/details")) .andRespond(MockRestResponseCreators.withSuccess("hello", MediaType.TEXT_PLAIN)) val greeting = service.callRestService() - Assertions.assertThat(greeting).isEqualTo("hello") + assertThat(greeting).isEqualTo("hello") } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredrestclient/RemoteVehicleDetailsService.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredrestclient/RemoteVehicleDetailsService.kt index ccb66083c47..f03184e7060 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredrestclient/RemoteVehicleDetailsService.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredrestclient/RemoteVehicleDetailsService.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,7 +17,9 @@ package org.springframework.boot.docs.features.testing.springbootapplications.autoconfiguredrestclient class RemoteVehicleDetailsService { + fun callRestService(): String { return "hello" } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatacassandra/MyDataCassandraTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatacassandra/MyDataCassandraTests.kt index a227563387c..0d12dd405d0 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatacassandra/MyDataCassandraTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatacassandra/MyDataCassandraTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -20,4 +20,4 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.data.cassandra.DataCassandraTest @DataCassandraTest -class MyDataCassandraTests(@Autowired val repository: SomeRepository) \ No newline at end of file +class MyDataCassandraTests(@Autowired val repository: SomeRepository) diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatacassandra/SomeRepository.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatacassandra/SomeRepository.kt index 71dc1aa708b..7d422fa1b9b 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatacassandra/SomeRepository.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatacassandra/SomeRepository.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.features.testing.springbootapplications.autoconfiguredspringdatacassandra -interface SomeRepository { -} \ No newline at end of file +interface SomeRepository diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/MyNonTransactionalTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/MyNonTransactionalTests.kt index 89f7ca7c6d2..40de9a76e7e 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/MyNonTransactionalTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/MyNonTransactionalTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -26,4 +26,4 @@ class MyNonTransactionalTests { // ... -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/withdb/MyRepositoryTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/withdb/MyRepositoryTests.kt index b5e9e6a6abd..51378c51e68 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/withdb/MyRepositoryTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/withdb/MyRepositoryTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,8 +21,8 @@ import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest @DataJpaTest @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) -class MyRepositoryTests() { +class MyRepositoryTests { // ... -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/MyRepositoryTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/MyRepositoryTests.kt index 46d0d36159d..ade356e18df 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/MyRepositoryTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/MyRepositoryTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,22 +16,21 @@ package org.springframework.boot.docs.features.testing.springbootapplications.autoconfiguredspringdatajpa.withoutdb -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager @DataJpaTest -class MyRepositoryTests( - @Autowired val entityManager: TestEntityManager, - @Autowired val repository: UserRepository) { +class MyRepositoryTests(@Autowired val entityManager: TestEntityManager, @Autowired val repository: UserRepository) { @Test fun testExample() { entityManager.persist(User("sboot", "1234")) val user = repository.findByUsername("sboot") - Assertions.assertThat(user?.username).isEqualTo("sboot") - Assertions.assertThat(user?.employeeNumber).isEqualTo("1234") + assertThat(user?.username).isEqualTo("sboot") + assertThat(user?.employeeNumber).isEqualTo("1234") } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/User.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/User.kt index e1315135947..a747adfa93c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/User.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/User.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,4 +16,4 @@ package org.springframework.boot.docs.features.testing.springbootapplications.autoconfiguredspringdatajpa.withoutdb -class User(val username: String, val employeeNumber: String) \ No newline at end of file +class User(val username: String, val employeeNumber: String) diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/UserRepository.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/UserRepository.kt index 0f87b3f223d..ae06280c40a 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/UserRepository.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatajpa/withoutdb/UserRepository.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,5 +17,7 @@ package org.springframework.boot.docs.features.testing.springbootapplications.autoconfiguredspringdatajpa.withoutdb interface UserRepository { + fun findByUsername(username: String?): User? -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataldap/inmemory/MyDataLdapTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataldap/inmemory/MyDataLdapTests.kt index 32af672cc51..285c37ade28 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataldap/inmemory/MyDataLdapTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataldap/inmemory/MyDataLdapTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -25,4 +25,4 @@ class MyDataLdapTests(@Autowired val ldapTemplate: LdapTemplate) { // ... -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataldap/server/MyDataLdapTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataldap/server/MyDataLdapTests.kt index 77d2ba84537..6265c7eb66c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataldap/server/MyDataLdapTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataldap/server/MyDataLdapTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,4 +24,4 @@ class MyDataLdapTests { // ... -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatamongodb/withdb/MyDataMongoDbTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatamongodb/withdb/MyDataMongoDbTests.kt index a1ee5681947..c75f1ad097f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatamongodb/withdb/MyDataMongoDbTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatamongodb/withdb/MyDataMongoDbTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,4 +24,4 @@ class MyDataMongoDbTests { // ... -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatamongodb/withoutdb/MyDataMongoDbTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatamongodb/withoutdb/MyDataMongoDbTests.kt index 725935219b0..67c6eb36f05 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatamongodb/withoutdb/MyDataMongoDbTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdatamongodb/withoutdb/MyDataMongoDbTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -25,4 +25,4 @@ class MyDataMongoDbTests(@Autowired val mongoTemplate: MongoTemplate) { // ... -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataneo4j/nopropagation/MyDataNeo4jTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataneo4j/nopropagation/MyDataNeo4jTests.kt index 72a716922c7..7460c673e28 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataneo4j/nopropagation/MyDataNeo4jTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataneo4j/nopropagation/MyDataNeo4jTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,4 +22,4 @@ import org.springframework.transaction.annotation.Transactional @DataNeo4jTest @Transactional(propagation = Propagation.NOT_SUPPORTED) -class MyDataNeo4jTests \ No newline at end of file +class MyDataNeo4jTests diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataneo4j/propagation/MyDataNeo4jTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataneo4j/propagation/MyDataNeo4jTests.kt index cb12c65b87a..c284cb6d668 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataneo4j/propagation/MyDataNeo4jTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataneo4j/propagation/MyDataNeo4jTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,4 +24,4 @@ class MyDataNeo4jTests(@Autowired val repository: SomeRepository) { // ... -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataneo4j/propagation/SomeRepository.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataneo4j/propagation/SomeRepository.kt index c19cf85a397..77b41f7fd07 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataneo4j/propagation/SomeRepository.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataneo4j/propagation/SomeRepository.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.features.testing.springbootapplications.autoconfiguredspringdataneo4j.propagation -interface SomeRepository { -} \ No newline at end of file +interface SomeRepository diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataredis/MyDataRedisTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataredis/MyDataRedisTests.kt index 4fb8d75740a..6b5e3dbb150 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataredis/MyDataRedisTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataredis/MyDataRedisTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,4 +24,4 @@ class MyDataRedisTests(@Autowired val repository: SomeRepository) { // ... -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataredis/SomeRepository.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataredis/SomeRepository.kt index 72a074abe0f..a27027bf603 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataredis/SomeRepository.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringdataredis/SomeRepository.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.features.testing.springbootapplications.autoconfiguredspringdataredis -interface SomeRepository { -} \ No newline at end of file +interface SomeRepository diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyRestDocsConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyRestDocsConfiguration.kt index c0c97fb96dc..afdcf491fc4 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyRestDocsConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyRestDocsConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,7 +23,9 @@ import org.springframework.restdocs.templates.TemplateFormats @TestConfiguration(proxyBeanMethods = false) class MyRestDocsConfiguration : RestDocsMockMvcConfigurationCustomizer { + override fun customize(configurer: MockMvcRestDocumentationConfigurer) { configurer.snippets().withTemplateFormat(TemplateFormats.markdown()) } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyResultHandlerConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyResultHandlerConfiguration.kt index 0c09ae5920f..44a53da8d91 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyResultHandlerConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyResultHandlerConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,8 +23,10 @@ import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler @TestConfiguration(proxyBeanMethods = false) class MyResultHandlerConfiguration { + @Bean fun restDocumentation(): RestDocumentationResultHandler { return MockMvcRestDocumentation.document("{method-name}") } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyUserDocumentationTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyUserDocumentationTests.kt index 945622ad105..3bdd188515e 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyUserDocumentationTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyUserDocumentationTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -29,12 +29,12 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers @WebMvcTest(UserController::class) @AutoConfigureRestDocs class MyUserDocumentationTests(@Autowired val mvc: MockMvc) { + @Test fun listUsers() { - // @formatter:off mvc.perform(MockMvcRequestBuilders.get("/users").accept(MediaType.TEXT_PLAIN)) .andExpect(MockMvcResultMatchers.status().isOk) .andDo(MockMvcRestDocumentation.document("list-users")) - // @formatter:on } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/UserController.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/UserController.kt index 5a57255fc4c..527b12d88dd 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/UserController.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/UserController.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.features.testing.springbootapplications.autoconfiguredspringrestdocs.withmockmvc -class UserController { -} \ No newline at end of file +class UserController diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyRestDocsConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyRestDocsConfiguration.kt index 67e2921c851..768531a161a 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyRestDocsConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyRestDocsConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,7 +23,9 @@ import org.springframework.restdocs.templates.TemplateFormats @TestConfiguration(proxyBeanMethods = false) class MyRestDocsConfiguration : RestDocsRestAssuredConfigurationCustomizer { + override fun customize(configurer: RestAssuredRestDocumentationConfigurer) { configurer.snippets().withTemplateFormat(TemplateFormats.markdown()) } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyUserDocumentationTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyUserDocumentationTests.kt index 087798da722..53efcbeea67 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyUserDocumentationTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyUserDocumentationTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -30,15 +30,15 @@ import org.springframework.restdocs.restassured3.RestAssuredRestDocumentation @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @AutoConfigureRestDocs class MyUserDocumentationTests { + @Test fun listUsers(@Autowired documentationSpec: RequestSpecification?, @LocalServerPort port: Int) { - // @formatter:off RestAssured.given(documentationSpec) .filter(RestAssuredRestDocumentation.document("list-users")) .`when`() .port(port)["/"] .then().assertThat() .statusCode(Matchers.`is`(200)) - // @formatter:on } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyRestDocsConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyRestDocsConfiguration.kt index f87ae19f90d..be95090d4c0 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyRestDocsConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyRestDocsConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,7 +22,9 @@ import org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation @TestConfiguration(proxyBeanMethods = false) class MyRestDocsConfiguration : RestDocsWebTestClientConfigurationCustomizer { + override fun customize(configurer: WebTestClientRestDocumentationConfigurer) { configurer.snippets().withEncoding("UTF-8") } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyUsersDocumentationTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyUsersDocumentationTests.kt index 4e28e5b99b8..fa75f024d27 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyUsersDocumentationTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyUsersDocumentationTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -26,9 +26,9 @@ import org.springframework.test.web.reactive.server.WebTestClient @WebFluxTest @AutoConfigureRestDocs class MyUsersDocumentationTests(@Autowired val webTestClient: WebTestClient) { + @Test fun listUsers() { - // @formatter:off webTestClient .get().uri("/") .exchange() @@ -36,6 +36,6 @@ class MyUsersDocumentationTests(@Autowired val webTestClient: WebTestClient) { .isOk .expectBody() .consumeWith(WebTestClientRestDocumentation.document("list-users")) - // @formatter:on } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyWebTestClientBuilderCustomizerConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyWebTestClientBuilderCustomizerConfiguration.kt index e38fb6f5d7b..157dc98d309 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyWebTestClientBuilderCustomizerConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyWebTestClientBuilderCustomizerConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,6 +24,7 @@ import org.springframework.test.web.reactive.server.WebTestClient @TestConfiguration(proxyBeanMethods = false) class MyWebTestClientBuilderCustomizerConfiguration { + @Bean fun restDocumentation(): WebTestClientBuilderCustomizer { return WebTestClientBuilderCustomizer { builder: WebTestClient.Builder -> @@ -32,4 +33,5 @@ class MyWebTestClientBuilderCustomizerConfiguration { ) } } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/client/MyWebServiceClientTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/client/MyWebServiceClientTests.kt index c5b01778267..a72ffe0ac3d 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/client/MyWebServiceClientTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/client/MyWebServiceClientTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,7 +16,7 @@ package org.springframework.boot.docs.features.testing.springbootapplications.autoconfiguredwebservices.client -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.webservices.client.WebServiceClientTest @@ -24,22 +24,16 @@ import org.springframework.ws.test.client.MockWebServiceServer import org.springframework.ws.test.client.RequestMatchers import org.springframework.ws.test.client.ResponseCreators import org.springframework.xml.transform.StringSource -import java.util.function.Function @WebServiceClientTest(SomeWebService::class) -class MyWebServiceClientTests( - @Autowired val server: MockWebServiceServer, - @Autowired val someWebService: SomeWebService) { +class MyWebServiceClientTests(@Autowired val server: MockWebServiceServer, @Autowired val someWebService: SomeWebService) { @Test fun mockServerCall() { - // @formatter:off server .expect(RequestMatchers.payload(StringSource(""))) .andRespond(ResponseCreators.withPayload(StringSource("200"))) - Assertions.assertThat(this.someWebService.test()) - .extracting(Function { obj: Response -> obj.status }) - .isEqualTo(200) - // @formatter:on + assertThat(this.someWebService.test()).extracting(Response::status).isEqualTo(200) } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/client/Request.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/client/Request.kt index e153d51ad43..cd9200928ad 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/client/Request.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/client/Request.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -19,6 +19,4 @@ package org.springframework.boot.docs.features.testing.springbootapplications.au import javax.xml.bind.annotation.XmlRootElement @XmlRootElement(name = "request") -class Request { - -} \ No newline at end of file +class Request diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/client/Response.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/client/Response.kt index fe87d7c4fd4..cea7a17a215 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/client/Response.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/client/Response.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,4 +24,4 @@ import javax.xml.bind.annotation.XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) class Response { val status = 0 -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/client/SomeWebService.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/client/SomeWebService.kt index 219ed8dc29e..b6bedacb577 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/client/SomeWebService.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/client/SomeWebService.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,12 +22,15 @@ import org.springframework.ws.client.core.WebServiceTemplate @Service class SomeWebService(builder: WebServiceTemplateBuilder) { + private val webServiceTemplate: WebServiceTemplate - fun test(): Response { - return webServiceTemplate.marshalSendAndReceive("https://example.com", Request()) as Response - } init { webServiceTemplate = builder.build() } -} \ No newline at end of file + + fun test(): Response { + return webServiceTemplate.marshalSendAndReceive("https://example.com", Request()) as Response + } + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/server/ExampleEndpoint.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/server/ExampleEndpoint.kt index cc257b6fb64..a1b7c8bc3aa 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/server/ExampleEndpoint.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/server/ExampleEndpoint.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,9 +24,11 @@ import javax.xml.transform.Source @Endpoint class ExampleEndpoint { + @PayloadRoot(localPart = "ExampleRequest") @ResponsePayload fun handleRequest(): Source { return StringSource("42") } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/server/MyWebServiceServerTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/server/MyWebServiceServerTests.kt index f4d68f23da1..ce4ef870dd3 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/server/MyWebServiceServerTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/autoconfiguredwebservices/server/MyWebServiceServerTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -29,10 +29,9 @@ class MyWebServiceServerTests(@Autowired val client: MockWebServiceClient) { @Test fun mockServerCall() { - // @formatter:off client .sendRequest(RequestCreators.withPayload(StringSource(""))) .andExpect(ResponseMatchers.payload(StringSource("42"))) - // @formatter:on } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/detectingwebapptype/MyWebFluxTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/detectingwebapptype/MyWebFluxTests.kt index 57ff3c1f877..4fe954cb6a2 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/detectingwebapptype/MyWebFluxTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/detectingwebapptype/MyWebFluxTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/excludingconfiguration/MyTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/excludingconfiguration/MyTests.kt index 06c1944a0c1..9582e085268 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/excludingconfiguration/MyTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/excludingconfiguration/MyTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -29,4 +29,4 @@ class MyTests { // ... } -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/excludingconfiguration/MyTestsConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/excludingconfiguration/MyTestsConfiguration.kt index 5d6e03da869..f2598ca0c9f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/excludingconfiguration/MyTestsConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/excludingconfiguration/MyTestsConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.features.testing.springbootapplications.excludingconfiguration -class MyTestsConfiguration { -} \ No newline at end of file +class MyTestsConfiguration diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jmx/MyJmxTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jmx/MyJmxTests.kt index f73d70c0561..17f0d836a0c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jmx/MyJmxTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jmx/MyJmxTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,7 +16,7 @@ package org.springframework.boot.docs.features.testing.springbootapplications.jmx -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.springframework.beans.factory.annotation.Autowired @@ -32,8 +32,8 @@ class MyJmxTests(@Autowired val mBeanServer: MBeanServer) { @Test fun exampleTest() { - Assertions.assertThat(mBeanServer.domains).contains("java.lang") + assertThat(mBeanServer.domains).contains("java.lang") // ... } -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jmx/SampleApp.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jmx/SampleApp.kt index 4ccf11b9937..c9428ec14d1 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jmx/SampleApp.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jmx/SampleApp.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,6 +22,4 @@ import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration @SpringBootConfiguration @ImportAutoConfiguration(JmxAutoConfiguration::class) -class SampleApp { - -} \ No newline at end of file +class SampleApp diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jsontests/MyJsonAssertJTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jsontests/MyJsonAssertJTests.kt index 6b03223791c..beea17d5de5 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jsontests/MyJsonAssertJTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jsontests/MyJsonAssertJTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,7 +16,8 @@ package org.springframework.boot.docs.features.testing.springbootapplications.jsontests -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.within import org.assertj.core.api.ThrowingConsumer import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired @@ -30,11 +31,11 @@ class MyJsonAssertJTests(@Autowired val json: JacksonTester) { @Test fun someTest() { val value = SomeObject(0.152f) - Assertions.assertThat(json.write(value)).extractingJsonPathNumberValue("@.test.numberValue") - .satisfies(ThrowingConsumer { number: Number -> - Assertions.assertThat( - number.toFloat() - ).isCloseTo(0.15f, Assertions.within(0.01f)) + assertThat(json.write(value)).extractingJsonPathNumberValue("@.test.numberValue") + .satisfies(ThrowingConsumer { number -> + assertThat(number.toFloat()).isCloseTo(0.15f, within(0.01f)) }) - } // end::code[] + } + // end::code[] + } diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jsontests/MyJsonTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jsontests/MyJsonTests.kt index 502efa6780c..6f13c309440 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jsontests/MyJsonTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jsontests/MyJsonTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,7 +16,7 @@ package org.springframework.boot.docs.features.testing.springbootapplications.jsontests -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.json.JsonTest @@ -24,22 +24,22 @@ import org.springframework.boot.test.json.JacksonTester @JsonTest class MyJsonTests(@Autowired val json: JacksonTester) { + @Test fun serialize() { val details = VehicleDetails("Honda", "Civic") // Assert against a `.json` file in the same package as the test - Assertions.assertThat(json.write(details)).isEqualToJson("expected.json") + assertThat(json.write(details)).isEqualToJson("expected.json") // Or use JSON path based assertions - Assertions.assertThat(json.write(details)).hasJsonPathStringValue("@.make") - Assertions.assertThat(json.write(details)).extractingJsonPathStringValue("@.make").isEqualTo("Honda") + assertThat(json.write(details)).hasJsonPathStringValue("@.make") + assertThat(json.write(details)).extractingJsonPathStringValue("@.make").isEqualTo("Honda") } @Test fun deserialize() { val content = "{\"make\":\"Ford\",\"model\":\"Focus\"}" - Assertions.assertThat( - json.parse(content) - ).isEqualTo(VehicleDetails("Ford", "Focus")) - Assertions.assertThat(json.parseObject(content).make).isEqualTo("Ford") + assertThat(json.parse(content)).isEqualTo(VehicleDetails("Ford", "Focus")) + assertThat(json.parseObject(content).make).isEqualTo("Ford") } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jsontests/SomeObject.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jsontests/SomeObject.kt index e7750b725d3..15a544a1d81 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jsontests/SomeObject.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jsontests/SomeObject.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,4 +16,5 @@ package org.springframework.boot.docs.features.testing.springbootapplications.jsontests -class SomeObject(value: Float) \ No newline at end of file +@Suppress("UNUSED_PARAMETER") +class SomeObject(value: Float) diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jsontests/VehicleDetails.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jsontests/VehicleDetails.kt index 469c5970bd4..4ae99479f6c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jsontests/VehicleDetails.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/jsontests/VehicleDetails.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/mockingbeans/bean/MyTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/mockingbeans/bean/MyTests.kt index b78447f445b..14833f41368 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/mockingbeans/bean/MyTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/mockingbeans/bean/MyTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,22 +16,21 @@ package org.springframework.boot.docs.features.testing.springbootapplications.mockingbeans.bean -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.mockito.BDDMockito +import org.mockito.BDDMockito.given import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import org.springframework.boot.test.mock.mockito.MockBean @SpringBootTest -class MyTests( - @Autowired val reverser: Reverser, - @MockBean val remoteService: RemoteService) { +class MyTests(@Autowired val reverser: Reverser, @MockBean val remoteService: RemoteService) { @Test fun exampleTest() { - BDDMockito.given(remoteService.value).willReturn("spring") + given(remoteService.value).willReturn("spring") val reverse = reverser.reverseValue // Calls injected RemoteService - Assertions.assertThat(reverse).isEqualTo("gnirps") + assertThat(reverse).isEqualTo("gnirps") } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/mockingbeans/bean/RemoteService.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/mockingbeans/bean/RemoteService.kt index 9749ec8819a..f79f32d26d7 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/mockingbeans/bean/RemoteService.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/mockingbeans/bean/RemoteService.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,6 +17,8 @@ package org.springframework.boot.docs.features.testing.springbootapplications.mockingbeans.bean class RemoteService { + val value: Any? get() = null -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/mockingbeans/bean/Reverser.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/mockingbeans/bean/Reverser.kt index 860910c5610..982aa813cac 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/mockingbeans/bean/Reverser.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/mockingbeans/bean/Reverser.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,6 +17,8 @@ package org.springframework.boot.docs.features.testing.springbootapplications.mockingbeans.bean class Reverser { + val reverseValue: String? get() = null + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/mockingbeans/listener/MyConfig.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/mockingbeans/listener/MyConfig.kt index 23abada160f..fb681d574ff 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/mockingbeans/listener/MyConfig.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/mockingbeans/listener/MyConfig.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.features.testing.springbootapplications.mockingbeans.listener -class MyConfig { -} \ No newline at end of file +class MyConfig diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/mockingbeans/listener/MyTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/mockingbeans/listener/MyTests.kt index 49f1c71fd91..66c4795b711 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/mockingbeans/listener/MyTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/mockingbeans/listener/MyTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.boot.docs.features.testing.springbootapplications.mockingbeans.listener import org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener @@ -20,7 +21,6 @@ import org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListene import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.TestExecutionListeners - @ContextConfiguration(classes = [MyConfig::class]) @TestExecutionListeners( MockitoTestExecutionListener::class, diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springgraphqltests/GreetingControllerTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springgraphqltests/GreetingControllerTests.kt new file mode 100644 index 00000000000..5f678663945 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springgraphqltests/GreetingControllerTests.kt @@ -0,0 +1,43 @@ +/* + * Copyright 2012-2022 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.features.testing.springbootapplications.springgraphqltests + +import org.junit.jupiter.api.Test +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.docs.web.graphql.runtimewiring.GreetingController +import org.springframework.boot.test.autoconfigure.graphql.GraphQlTest +import org.springframework.graphql.test.tester.GraphQlTester + +@GraphQlTest(GreetingController::class) +internal class GreetingControllerTests { + + @Autowired + lateinit var graphQlTester: GraphQlTester + + @Test + fun shouldGreetWithSpecificName() { + graphQlTester.query("{ greeting(name: \"Alice\") } ").execute().path("greeting").entity(String::class.java) + .isEqualTo("Hello, Alice!") + } + + @Test + fun shouldGreetWithDefaultName() { + graphQlTester.query("{ greeting } ").execute().path("greeting").entity(String::class.java) + .isEqualTo("Hello, Spring!") + } + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springmvctests/MyControllerTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springmvctests/MyControllerTests.kt index 5ca11204fc5..9879efc62a0 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springmvctests/MyControllerTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springmvctests/MyControllerTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,7 +17,7 @@ package org.springframework.boot.docs.features.testing.springbootapplications.springmvctests import org.junit.jupiter.api.Test -import org.mockito.BDDMockito +import org.mockito.BDDMockito.given import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest import org.springframework.boot.test.mock.mockito.MockBean @@ -27,22 +27,18 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders import org.springframework.test.web.servlet.result.MockMvcResultMatchers @WebMvcTest(UserVehicleController::class) -class MyControllerTests( - @Autowired val mvc: MockMvc) { +class MyControllerTests(@Autowired val mvc: MockMvc) { @MockBean lateinit var userVehicleService: UserVehicleService @Test fun testExample() { - // @formatter:off - BDDMockito.given( - userVehicleService.getVehicleDetails("sboot") - ) + given(userVehicleService.getVehicleDetails("sboot")) .willReturn(VehicleDetails("Honda", "Civic")) mvc.perform(MockMvcRequestBuilders.get("/sboot/vehicle").accept(MediaType.TEXT_PLAIN)) .andExpect(MockMvcResultMatchers.status().isOk) .andExpect(MockMvcResultMatchers.content().string("Honda Civic")) - // @formatter:on } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springmvctests/MyHtmlUnitTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springmvctests/MyHtmlUnitTests.kt index e93b82129f5..27119f4052f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springmvctests/MyHtmlUnitTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springmvctests/MyHtmlUnitTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -18,26 +18,24 @@ package org.springframework.boot.docs.features.testing.springbootapplications.sp import com.gargoylesoftware.htmlunit.WebClient import com.gargoylesoftware.htmlunit.html.HtmlPage -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.mockito.BDDMockito +import org.mockito.BDDMockito.given import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest import org.springframework.boot.test.mock.mockito.MockBean @WebMvcTest(UserVehicleController::class) -class MyHtmlUnitTests( - @Autowired val webClient: WebClient) { +class MyHtmlUnitTests(@Autowired val webClient: WebClient) { @MockBean lateinit var userVehicleService: UserVehicleService @Test fun testExample() { - BDDMockito.given( - userVehicleService.getVehicleDetails("sboot") - ).willReturn(VehicleDetails("Honda", "Civic")) + given(userVehicleService.getVehicleDetails("sboot")).willReturn(VehicleDetails("Honda", "Civic")) val page = webClient.getPage("/sboot/vehicle.html") - Assertions.assertThat(page.body.textContent).isEqualTo("Honda Civic") + assertThat(page.body.textContent).isEqualTo("Honda Civic") } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springmvctests/UserVehicleController.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springmvctests/UserVehicleController.kt index 612c7c3609d..45d6c3d2a88 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springmvctests/UserVehicleController.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springmvctests/UserVehicleController.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.features.testing.springbootapplications.springmvctests -class UserVehicleController { -} \ No newline at end of file +class UserVehicleController diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springmvctests/UserVehicleService.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springmvctests/UserVehicleService.kt index 6884b045f02..3a9c1453218 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springmvctests/UserVehicleService.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springmvctests/UserVehicleService.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,8 +16,11 @@ package org.springframework.boot.docs.features.testing.springbootapplications.springmvctests +@Suppress("UNUSED_PARAMETER") class UserVehicleService { + fun getVehicleDetails(name: String?): VehicleDetails? { return null } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springmvctests/VehicleDetails.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springmvctests/VehicleDetails.kt index 52878643f8a..a8032d5f43c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springmvctests/VehicleDetails.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springmvctests/VehicleDetails.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,4 +16,4 @@ package org.springframework.boot.docs.features.testing.springbootapplications.springmvctests -data class VehicleDetails(val make: String, val model: String) \ No newline at end of file +data class VehicleDetails(val make: String, val model: String) diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springwebfluxtests/MyControllerTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springwebfluxtests/MyControllerTests.kt index a8d6c8b562a..ab2d64e11e7 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springwebfluxtests/MyControllerTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springwebfluxtests/MyControllerTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,7 +17,7 @@ package org.springframework.boot.docs.features.testing.springbootapplications.springwebfluxtests import org.junit.jupiter.api.Test -import org.mockito.BDDMockito +import org.mockito.BDDMockito.given import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest import org.springframework.boot.test.mock.mockito.MockBean @@ -26,22 +26,18 @@ import org.springframework.test.web.reactive.server.WebTestClient import org.springframework.test.web.reactive.server.expectBody @WebFluxTest(UserVehicleController::class) -class MyControllerTests( - @Autowired val webClient: WebTestClient) { +class MyControllerTests(@Autowired val webClient: WebTestClient) { @MockBean lateinit var userVehicleService: UserVehicleService @Test fun testExample() { - // @formatter:off - BDDMockito.given( - userVehicleService.getVehicleDetails("sboot") - ) + given(userVehicleService.getVehicleDetails("sboot")) .willReturn(VehicleDetails("Honda", "Civic")) webClient.get().uri("/sboot/vehicle").accept(MediaType.TEXT_PLAIN).exchange() .expectStatus().isOk .expectBody().isEqualTo("Honda Civic") - // @formatter:on } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springwebfluxtests/UserVehicleController.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springwebfluxtests/UserVehicleController.kt index 31fb33c9417..ccd70bd0b70 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springwebfluxtests/UserVehicleController.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springwebfluxtests/UserVehicleController.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.features.testing.springbootapplications.springwebfluxtests -class UserVehicleController { -} \ No newline at end of file +class UserVehicleController \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springwebfluxtests/UserVehicleService.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springwebfluxtests/UserVehicleService.kt index dee395c43b9..b1a7448224d 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springwebfluxtests/UserVehicleService.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springwebfluxtests/UserVehicleService.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,8 +16,11 @@ package org.springframework.boot.docs.features.testing.springbootapplications.springwebfluxtests +@Suppress("UNUSED_PARAMETER") class UserVehicleService { + fun getVehicleDetails(name: String?): VehicleDetails? { return null } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springwebfluxtests/VehicleDetails.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springwebfluxtests/VehicleDetails.kt index e51327110fb..5ca26c27d3a 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springwebfluxtests/VehicleDetails.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/springwebfluxtests/VehicleDetails.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,4 +16,4 @@ package org.springframework.boot.docs.features.testing.springbootapplications.springwebfluxtests -data class VehicleDetails(val make: String, val model: String) \ No newline at end of file +data class VehicleDetails(val make: String, val model: String) diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/userconfigurationandslicing/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/userconfigurationandslicing/MyApplication.kt index 2aea7cab694..c7f18c7289f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/userconfigurationandslicing/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/userconfigurationandslicing/MyApplication.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -25,4 +25,4 @@ class MyApplication { // ... -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/userconfigurationandslicing/MyBatchConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/userconfigurationandslicing/MyBatchConfiguration.kt index d4085411b01..3ec1eabf611 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/userconfigurationandslicing/MyBatchConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/userconfigurationandslicing/MyBatchConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -25,4 +25,4 @@ class MyBatchConfiguration { // ... -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/userconfigurationandslicing/MyWebConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/userconfigurationandslicing/MyWebConfiguration.kt index 2a9d63f412b..38372dbc808 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/userconfigurationandslicing/MyWebConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/userconfigurationandslicing/MyWebConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,10 +22,12 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer @Configuration(proxyBeanMethods = false) class MyWebConfiguration { + @Bean fun testConfigurer(): WebMvcConfigurer { return object : WebMvcConfigurer { // ... } } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/userconfigurationandslicing/MyWebMvcConfigurer.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/userconfigurationandslicing/MyWebMvcConfigurer.kt index a4427a74b11..7168fa99035 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/userconfigurationandslicing/MyWebMvcConfigurer.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/userconfigurationandslicing/MyWebMvcConfigurer.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,4 +24,4 @@ class MyWebMvcConfigurer : WebMvcConfigurer { // ... -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/userconfigurationandslicing/scan/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/userconfigurationandslicing/scan/MyApplication.kt index 02189734e7d..75b0ade0b5e 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/userconfigurationandslicing/scan/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/userconfigurationandslicing/scan/MyApplication.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -25,4 +25,4 @@ class MyApplication { // ... -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/usingapplicationarguments/MyApplicationArgumentTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/usingapplicationarguments/MyApplicationArgumentTests.kt index e784e5d4ca0..dcc79a971e2 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/usingapplicationarguments/MyApplicationArgumentTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/usingapplicationarguments/MyApplicationArgumentTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,7 +16,7 @@ package org.springframework.boot.docs.features.testing.springbootapplications.usingapplicationarguments -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.ApplicationArguments @@ -24,9 +24,11 @@ import org.springframework.boot.test.context.SpringBootTest @SpringBootTest(args = ["--app.test=one"]) class MyApplicationArgumentTests { + @Test fun applicationArgumentsPopulated(@Autowired args: ApplicationArguments) { - Assertions.assertThat(args.optionNames).containsOnly("app.test") - Assertions.assertThat(args.getOptionValues("app.test")).containsOnly("one") + assertThat(args.optionNames).containsOnly("app.test") + assertThat(args.getOptionValues("app.test")).containsOnly("one") } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/withmockenvironment/MyMockMvcTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/withmockenvironment/MyMockMvcTests.kt index de280d5e3c4..10e10bae2f5 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/withmockenvironment/MyMockMvcTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/withmockenvironment/MyMockMvcTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,15 +21,15 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc import org.springframework.boot.test.context.SpringBootTest import org.springframework.test.web.reactive.server.WebTestClient +import org.springframework.test.web.reactive.server.expectBody import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders import org.springframework.test.web.servlet.result.MockMvcResultMatchers -import org.springframework.test.web.reactive.server.expectBody - @SpringBootTest @AutoConfigureMockMvc class MyMockMvcTests { + @Test fun testWithMockMvc(@Autowired mvc: MockMvc) { mvc.perform(MockMvcRequestBuilders.get("/")).andExpect(MockMvcResultMatchers.status().isOk) @@ -37,14 +37,14 @@ class MyMockMvcTests { } // If Spring WebFlux is on the classpath, you can drive MVC tests with a WebTestClient + @Test fun testWithWebTestClient(@Autowired webClient: WebTestClient) { - // @formatter:off webClient .get().uri("/") .exchange() .expectStatus().isOk .expectBody().isEqualTo("Hello World") - // @formatter:on } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/withmockenvironment/MyMockWebTestClientTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/withmockenvironment/MyMockWebTestClientTests.kt index 19fdb9c2993..08adafec587 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/withmockenvironment/MyMockWebTestClientTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/withmockenvironment/MyMockWebTestClientTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -26,14 +26,14 @@ import org.springframework.test.web.reactive.server.expectBody @SpringBootTest @AutoConfigureWebTestClient class MyMockWebTestClientTests { + @Test fun exampleTest(@Autowired webClient: WebTestClient) { - // @formatter:off webClient .get().uri("/") .exchange() .expectStatus().isOk .expectBody().isEqualTo("Hello World") - // @formatter:on } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/withrunningserver/MyRandomPortTestRestTemplateTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/withrunningserver/MyRandomPortTestRestTemplateTests.kt index b378c67a89f..1a769cfd637 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/withrunningserver/MyRandomPortTestRestTemplateTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/withrunningserver/MyRandomPortTestRestTemplateTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,7 +16,7 @@ package org.springframework.boot.docs.features.testing.springbootapplications.withrunningserver -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest @@ -25,9 +25,11 @@ import org.springframework.boot.test.web.client.TestRestTemplate @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) class MyRandomPortTestRestTemplateTests { + @Test fun exampleTest(@Autowired restTemplate: TestRestTemplate) { val body = restTemplate.getForObject("/", String::class.java) - Assertions.assertThat(body).isEqualTo("Hello World") + assertThat(body).isEqualTo("Hello World") } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/withrunningserver/MyRandomPortWebTestClientTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/withrunningserver/MyRandomPortWebTestClientTests.kt index 01320aeaab8..9d3aa693037 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/withrunningserver/MyRandomPortWebTestClientTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/springbootapplications/withrunningserver/MyRandomPortWebTestClientTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -25,14 +25,14 @@ import org.springframework.test.web.reactive.server.expectBody @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) class MyRandomPortWebTestClientTests { + @Test fun exampleTest(@Autowired webClient: WebTestClient) { - // @formatter:off webClient .get().uri("/") .exchange() .expectStatus().isOk .expectBody().isEqualTo("Hello World") - // @formatter:on } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/configdataapplicationcontextinitializer/Config.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/configdataapplicationcontextinitializer/Config.kt index 162521271ba..ed2572df2af 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/configdataapplicationcontextinitializer/Config.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/configdataapplicationcontextinitializer/Config.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.features.testing.utilities.configdataapplicationcontextinitializer -class Config { -} \ No newline at end of file +class Config diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/configdataapplicationcontextinitializer/MyConfigFileTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/configdataapplicationcontextinitializer/MyConfigFileTests.kt index 5f265e00d7c..b61258c6b76 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/configdataapplicationcontextinitializer/MyConfigFileTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/configdataapplicationcontextinitializer/MyConfigFileTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,4 +24,4 @@ class MyConfigFileTests { // ... -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/outputcapture/MyOutputCaptureTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/outputcapture/MyOutputCaptureTests.kt index c51c90fc3ca..dfbc0175952 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/outputcapture/MyOutputCaptureTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/outputcapture/MyOutputCaptureTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,7 +16,7 @@ package org.springframework.boot.docs.features.testing.utilities.outputcapture -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.springframework.boot.test.system.CapturedOutput @@ -24,9 +24,11 @@ import org.springframework.boot.test.system.OutputCaptureExtension @ExtendWith(OutputCaptureExtension::class) class MyOutputCaptureTests { + @Test fun testName(output: CapturedOutput?) { println("Hello World!") - Assertions.assertThat(output).contains("World") + assertThat(output).contains("World") } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/testpropertyvalues/MyEnvironmentTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/testpropertyvalues/MyEnvironmentTests.kt index ea118dfc401..eddf9ab0c4e 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/testpropertyvalues/MyEnvironmentTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/testpropertyvalues/MyEnvironmentTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,16 +16,18 @@ package org.springframework.boot.docs.features.testing.utilities.testpropertyvalues -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.boot.test.util.TestPropertyValues import org.springframework.mock.env.MockEnvironment class MyEnvironmentTests { + @Test fun testPropertySources() { val environment = MockEnvironment() TestPropertyValues.of("org=Spring", "name=Boot").applyTo(environment) - Assertions.assertThat(environment.getProperty("name")).isEqualTo("Boot") + assertThat(environment.getProperty("name")).isEqualTo("Boot") } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/testresttemplate/MySpringBootTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/testresttemplate/MySpringBootTests.kt index 53a42c843c9..35ca9739657 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/testresttemplate/MySpringBootTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/testresttemplate/MySpringBootTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,7 +16,7 @@ package org.springframework.boot.docs.features.testing.utilities.testresttemplate -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest @@ -29,21 +29,22 @@ import java.time.Duration @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) class MySpringBootTests(@Autowired val template: TestRestTemplate) { + @Test fun testRequest() { - val headers = template.getForEntity( - "/example", - String::class.java - ).headers - Assertions.assertThat(headers.location).hasHost("other.example.com") + val headers = template.getForEntity("/example", String::class.java).headers + assertThat(headers.location).hasHost("other.example.com") } @TestConfiguration(proxyBeanMethods = false) internal class RestTemplateBuilderConfiguration { + @Bean fun restTemplateBuilder(): RestTemplateBuilder { return RestTemplateBuilder().setConnectTimeout(Duration.ofSeconds(1)) .setReadTimeout(Duration.ofSeconds(1)) } + } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/testresttemplate/MySpringBootTestsConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/testresttemplate/MySpringBootTestsConfiguration.kt index 76c2cc85a29..5bb52cd03a6 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/testresttemplate/MySpringBootTestsConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/testresttemplate/MySpringBootTestsConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -35,11 +35,15 @@ import java.net.URI HttpMessageConvertersAutoConfiguration::class ) class MySpringBootTestsConfiguration { + @RestController private class ExampleController { + @RequestMapping("/example") fun example(): ResponseEntity { return ResponseEntity.ok().location(URI.create("https://other.example.com/example")).body("test") } + } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/testresttemplate/MyTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/testresttemplate/MyTests.kt index 3671e4dccd5..d6bd28b1013 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/testresttemplate/MyTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/testing/utilities/testresttemplate/MyTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,18 +16,18 @@ package org.springframework.boot.docs.features.testing.utilities.testresttemplate -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.boot.test.web.client.TestRestTemplate class MyTests { + private val template = TestRestTemplate() + @Test fun testRequest() { - val headers = template.getForEntity( - "https://myhost.example.com/example", - String::class.java - ) - Assertions.assertThat(headers.headers.location).hasHost("other.example.com") + val headers = template.getForEntity("https://myhost.example.com/example", String::class.java) + assertThat(headers.headers.location).hasHost("other.example.com") } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/gettingstarted/firstapplication/code/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/gettingstarted/firstapplication/code/MyApplication.kt index ab118b90eca..798f5d3b507 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/gettingstarted/firstapplication/code/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/gettingstarted/firstapplication/code/MyApplication.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,8 +24,10 @@ import org.springframework.web.bind.annotation.RestController @RestController @EnableAutoConfiguration class MyApplication { + @RequestMapping("/") fun home() = "Hello World!" + } fun main(args: Array) { diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/actuator/maphealthindicatorstometrics/MetricsHealthMicrometerExport.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/actuator/maphealthindicatorstometrics/MetricsHealthMicrometerExport.kt index 37397049651..cecce3bd5dd 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/actuator/maphealthindicatorstometrics/MetricsHealthMicrometerExport.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/actuator/maphealthindicatorstometrics/MetricsHealthMicrometerExport.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.howto.actuator.maphealthindicatorstometrics -class MetricsHealthMicrometerExport { -} \ No newline at end of file +class MetricsHealthMicrometerExport diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/actuator/maphealthindicatorstometrics/MyHealthMetricsExportConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/actuator/maphealthindicatorstometrics/MyHealthMetricsExportConfiguration.kt index aec5e54d091..86941041b23 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/actuator/maphealthindicatorstometrics/MyHealthMetricsExportConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/actuator/maphealthindicatorstometrics/MyHealthMetricsExportConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,13 +24,11 @@ import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) class MyHealthMetricsExportConfiguration(registry: MeterRegistry, healthEndpoint: HealthEndpoint) { + init { // This example presumes common tags (such as the app) are applied elsewhere - Gauge.builder( - "health", healthEndpoint - ) { health: HealthEndpoint -> - getStatusCode(health) - .toDouble() + Gauge.builder("health", healthEndpoint) { health -> + getStatusCode(health).toDouble() }.strongReference(true).register(registry) } @@ -42,8 +40,10 @@ class MyHealthMetricsExportConfiguration(registry: MeterRegistry, healthEndpoint if (Status.OUT_OF_SERVICE == status) { return 2 } - return if (Status.DOWN == status) { - 1 - } else 0 + if (Status.DOWN == status) { + return 1 + } + return 0 } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/application/customizetheenvironmentorapplicationcontext/MyEnvironmentPostProcessor.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/application/customizetheenvironmentorapplicationcontext/MyEnvironmentPostProcessor.kt index 13d41085fce..46457d1da1a 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/application/customizetheenvironmentorapplicationcontext/MyEnvironmentPostProcessor.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/application/customizetheenvironmentorapplicationcontext/MyEnvironmentPostProcessor.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -27,7 +27,9 @@ import org.springframework.util.Assert import java.io.IOException class MyEnvironmentPostProcessor : EnvironmentPostProcessor { + private val loader = YamlPropertySourceLoader() + override fun postProcessEnvironment(environment: ConfigurableEnvironment, application: SpringApplication) { val path: Resource = ClassPathResource("com/example/myapp/config.yml") val propertySource = loadYaml(path) @@ -42,4 +44,5 @@ class MyEnvironmentPostProcessor : EnvironmentPostProcessor { throw IllegalStateException("Failed to load yaml configuration from $path", ex) } } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configureacomponentthatisusedbyjpa/ElasticsearchEntityManagerFactoryDependsOnPostProcessor.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configureacomponentthatisusedbyjpa/ElasticsearchEntityManagerFactoryDependsOnPostProcessor.kt index 1674dc69020..e705d82f99a 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configureacomponentthatisusedbyjpa/ElasticsearchEntityManagerFactoryDependsOnPostProcessor.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configureacomponentthatisusedbyjpa/ElasticsearchEntityManagerFactoryDependsOnPostProcessor.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,4 +21,4 @@ import org.springframework.stereotype.Component @Component class ElasticsearchEntityManagerFactoryDependsOnPostProcessor : - EntityManagerFactoryDependsOnPostProcessor("elasticsearchClient") \ No newline at end of file + EntityManagerFactoryDependsOnPostProcessor("elasticsearchClient") diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurecustomdatasource/builder/MyDataSourceConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurecustomdatasource/builder/MyDataSourceConfiguration.kt index f74aa26b233..ff5731a5563 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurecustomdatasource/builder/MyDataSourceConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurecustomdatasource/builder/MyDataSourceConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,9 +24,11 @@ import javax.sql.DataSource @Configuration(proxyBeanMethods = false) class MyDataSourceConfiguration { + @Bean @ConfigurationProperties("app.datasource") fun dataSource(): DataSource { return DataSourceBuilder.create().build() } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurecustomdatasource/configurable/MyDataSourceConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurecustomdatasource/configurable/MyDataSourceConfiguration.kt index 1dafbf4bbd9..94e1a05a5af 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurecustomdatasource/configurable/MyDataSourceConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurecustomdatasource/configurable/MyDataSourceConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -25,6 +25,7 @@ import org.springframework.context.annotation.Primary @Configuration(proxyBeanMethods = false) class MyDataSourceConfiguration { + @Bean @Primary @ConfigurationProperties("app.datasource") @@ -37,4 +38,5 @@ class MyDataSourceConfiguration { fun dataSource(properties: DataSourceProperties): HikariDataSource { return properties.initializeDataSourceBuilder().type(HikariDataSource::class.java).build() } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurecustomdatasource/custom/MyDataSourceConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurecustomdatasource/custom/MyDataSourceConfiguration.kt index bd234138f2c..da7e2d11fa3 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurecustomdatasource/custom/MyDataSourceConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurecustomdatasource/custom/MyDataSourceConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,9 +22,11 @@ import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) class MyDataSourceConfiguration { + @Bean @ConfigurationProperties(prefix = "app.datasource") fun dataSource(): SomeDataSource { return SomeDataSource() } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurecustomdatasource/custom/SomeDataSource.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurecustomdatasource/custom/SomeDataSource.kt index a8faece02ea..cc1136d8420 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurecustomdatasource/custom/SomeDataSource.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurecustomdatasource/custom/SomeDataSource.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.howto.dataaccess.configurecustomdatasource.custom -class SomeDataSource { -} \ No newline at end of file +class SomeDataSource diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurecustomdatasource/simple/MyDataSourceConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurecustomdatasource/simple/MyDataSourceConfiguration.kt index a94d621d7a9..42edfe2ca4f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurecustomdatasource/simple/MyDataSourceConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurecustomdatasource/simple/MyDataSourceConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,9 +24,11 @@ import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) class MyDataSourceConfiguration { + @Bean @ConfigurationProperties("app.datasource") fun dataSource(): HikariDataSource { return DataSourceBuilder.create().type(HikariDataSource::class.java).build() } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurehibernatenamingstrategy/spring/MyHibernateConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurehibernatenamingstrategy/spring/MyHibernateConfiguration.kt index 93d80c0d542..c102def20cc 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurehibernatenamingstrategy/spring/MyHibernateConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurehibernatenamingstrategy/spring/MyHibernateConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,6 +23,7 @@ import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) class MyHibernateConfiguration { + @Bean fun caseSensitivePhysicalNamingStrategy(): CamelCaseToUnderscoresNamingStrategy { return object : CamelCaseToUnderscoresNamingStrategy() { @@ -31,4 +32,5 @@ class MyHibernateConfiguration { } } } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurehibernatenamingstrategy/standard/MyHibernateConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurehibernatenamingstrategy/standard/MyHibernateConfiguration.kt index eae49841940..4ec13dba01f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurehibernatenamingstrategy/standard/MyHibernateConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurehibernatenamingstrategy/standard/MyHibernateConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,8 +22,10 @@ import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) internal class MyHibernateConfiguration { + @Bean fun caseSensitivePhysicalNamingStrategy(): PhysicalNamingStrategyStandardImpl { return PhysicalNamingStrategyStandardImpl() } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurehibernatesecondlevelcaching/MyHibernateSecondLevelCacheConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurehibernatesecondlevelcaching/MyHibernateSecondLevelCacheConfiguration.kt index c2159783cdc..fc5973da76f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurehibernatesecondlevelcaching/MyHibernateSecondLevelCacheConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurehibernatesecondlevelcaching/MyHibernateSecondLevelCacheConfiguration.kt @@ -1,3 +1,19 @@ +/* + * Copyright 2012-2022 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.boot.docs.howto.dataaccess.configurehibernatesecondlevelcaching import org.hibernate.cache.jcache.ConfigSettings @@ -8,10 +24,12 @@ import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) class MyHibernateSecondLevelCacheConfiguration { + @Bean fun hibernateSecondLevelCacheCustomizer(cacheManager: JCacheCacheManager): HibernatePropertiesCustomizer { - return HibernatePropertiesCustomizer { properties: MutableMap -> + return HibernatePropertiesCustomizer { properties -> properties[ConfigSettings.CACHE_MANAGER] = cacheManager.cacheManager } } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configuretwodatasources/MyCompleteDataSourcesConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configuretwodatasources/MyCompleteDataSourcesConfiguration.kt index 96dbc402e2a..24d142717a0 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configuretwodatasources/MyCompleteDataSourcesConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configuretwodatasources/MyCompleteDataSourcesConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -26,6 +26,7 @@ import org.springframework.context.annotation.Primary @Configuration(proxyBeanMethods = false) class MyCompleteDataSourcesConfiguration { + @Bean @Primary @ConfigurationProperties("app.datasource.first") @@ -51,4 +52,5 @@ class MyCompleteDataSourcesConfiguration { fun secondDataSource(secondDataSourceProperties: DataSourceProperties): BasicDataSource { return secondDataSourceProperties.initializeDataSourceBuilder().type(BasicDataSource::class.java).build() } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configuretwodatasources/MyDataSourcesConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configuretwodatasources/MyDataSourcesConfiguration.kt index 2ea96f635de..2e47fb8b10c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configuretwodatasources/MyDataSourcesConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configuretwodatasources/MyDataSourcesConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -27,6 +27,7 @@ import org.springframework.context.annotation.Primary @Configuration(proxyBeanMethods = false) class MyDataSourcesConfiguration { + @Bean @Primary @ConfigurationProperties("app.datasource.first") @@ -46,4 +47,5 @@ class MyDataSourcesConfiguration { fun secondDataSource(): BasicDataSource { return DataSourceBuilder.create().type(BasicDataSource::class.java).build() } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/separateentitydefinitionsfromspringconfiguration/City.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/separateentitydefinitionsfromspringconfiguration/City.kt index bb7c54d2bdc..e9f5f61ee7e 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/separateentitydefinitionsfromspringconfiguration/City.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/separateentitydefinitionsfromspringconfiguration/City.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.howto.dataaccess.separateentitydefinitionsfromspringconfiguration -class City { -} \ No newline at end of file +class City diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/separateentitydefinitionsfromspringconfiguration/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/separateentitydefinitionsfromspringconfiguration/MyApplication.kt index bb14b0629eb..a23b49e5a2c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/separateentitydefinitionsfromspringconfiguration/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/separateentitydefinitionsfromspringconfiguration/MyApplication.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -27,4 +27,4 @@ class MyApplication { // ... -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/Customer.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/Customer.kt index 7bf6b7669ac..b8bac247643 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/Customer.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/Customer.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.howto.dataaccess.usemultipleentitymanagers -class Customer { -} \ No newline at end of file +class Customer diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/CustomerConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/CustomerConfiguration.kt index 00711029db1..3ae2042a864 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/CustomerConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/CustomerConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,4 +21,4 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories @Configuration(proxyBeanMethods = false) @EnableJpaRepositories(basePackageClasses = [Customer::class], entityManagerFactoryRef = "secondEntityManagerFactory") -class CustomerConfiguration \ No newline at end of file +class CustomerConfiguration diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/MyEntityManagerFactoryConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/MyEntityManagerFactoryConfiguration.kt index 24b8e64c16a..411225c0ff4 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/MyEntityManagerFactoryConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/MyEntityManagerFactoryConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -26,8 +26,10 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter import javax.sql.DataSource +@Suppress("UNUSED_PARAMETER") @Configuration(proxyBeanMethods = false) class MyEntityManagerFactoryConfiguration { + @Bean @ConfigurationProperties("app.jpa.first") fun firstJpaProperties(): JpaProperties { @@ -52,4 +54,5 @@ class MyEntityManagerFactoryConfiguration { // ... map JPA properties as needed return HibernateJpaVendorAdapter() } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/Order.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/Order.kt index 5edeee0aec1..3cafe7769a3 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/Order.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/Order.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.howto.dataaccess.usemultipleentitymanagers -class Order { -} \ No newline at end of file +class Order diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/OrderConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/OrderConfiguration.kt index e0861214062..01aaecea516 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/OrderConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/OrderConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,4 +21,4 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories @Configuration(proxyBeanMethods = false) @EnableJpaRepositories(basePackageClasses = [Order::class], entityManagerFactoryRef = "firstEntityManagerFactory") -class OrderConfiguration \ No newline at end of file +class OrderConfiguration diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/httpclients/webclientreactornettycustomization/MyReactorNettyClientConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/httpclients/webclientreactornettycustomization/MyReactorNettyClientConfiguration.kt index ca1d9d1f634..85c140e3f07 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/httpclients/webclientreactornettycustomization/MyReactorNettyClientConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/httpclients/webclientreactornettycustomization/MyReactorNettyClientConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,23 +23,20 @@ import org.springframework.context.annotation.Configuration import org.springframework.http.client.reactive.ClientHttpConnector import org.springframework.http.client.reactive.ReactorClientHttpConnector import org.springframework.http.client.reactive.ReactorResourceFactory -import reactor.netty.Connection import reactor.netty.http.client.HttpClient @Configuration(proxyBeanMethods = false) class MyReactorNettyClientConfiguration { + @Bean fun clientHttpConnector(resourceFactory: ReactorResourceFactory): ClientHttpConnector { - // @formatter:off val httpClient = HttpClient.create(resourceFactory.connectionProvider) .runOn(resourceFactory.loopResources) .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 60000) - .doOnConnected { connection: Connection -> - connection.addHandlerLast( - ReadTimeoutHandler(60) - ) + .doOnConnected { connection -> + connection.addHandlerLast(ReadTimeoutHandler(60)) } return ReactorClientHttpConnector(httpClient) - // @formatter:on } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/jersey/alongsideanotherwebframework/Endpoint.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/jersey/alongsideanotherwebframework/Endpoint.kt index 20789131e49..1c306250905 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/jersey/alongsideanotherwebframework/Endpoint.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/jersey/alongsideanotherwebframework/Endpoint.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.howto.jersey.alongsideanotherwebframework -class Endpoint { -} \ No newline at end of file +class Endpoint diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/jersey/alongsideanotherwebframework/JerseyConfig.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/jersey/alongsideanotherwebframework/JerseyConfig.kt index a641ba3e639..3c3b95234a3 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/jersey/alongsideanotherwebframework/JerseyConfig.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/jersey/alongsideanotherwebframework/JerseyConfig.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,8 +22,10 @@ import org.springframework.stereotype.Component @Component class JerseyConfig : ResourceConfig() { + init { register(Endpoint::class.java) property(ServletProperties.FILTER_FORWARD_ON_404, true) } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/jersey/springsecurity/Endpoint.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/jersey/springsecurity/Endpoint.kt index 4825fb4f495..8128fdc191d 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/jersey/springsecurity/Endpoint.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/jersey/springsecurity/Endpoint.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.howto.jersey.springsecurity -class Endpoint { -} \ No newline at end of file +class Endpoint diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/jersey/springsecurity/JerseySetStatusOverSendErrorConfig.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/jersey/springsecurity/JerseySetStatusOverSendErrorConfig.kt index 419540530a1..7a0de28a708 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/jersey/springsecurity/JerseySetStatusOverSendErrorConfig.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/jersey/springsecurity/JerseySetStatusOverSendErrorConfig.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -18,12 +18,14 @@ package org.springframework.boot.docs.howto.jersey.springsecurity import org.glassfish.jersey.server.ResourceConfig import org.springframework.stereotype.Component -import java.util.* +import java.util.Collections @Component class JerseySetStatusOverSendErrorConfig : ResourceConfig() { + init { register(Endpoint::class.java) setProperties(Collections.singletonMap("jersey.config.server.response.setStatusOverSendError", true)) } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/messaging/disabletransactedjmssession/MyJmsConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/messaging/disabletransactedjmssession/MyJmsConfiguration.kt index fd551a33f56..db362af7125 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/messaging/disabletransactedjmssession/MyJmsConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/messaging/disabletransactedjmssession/MyJmsConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,17 +22,18 @@ import org.springframework.context.annotation.Configuration import org.springframework.jms.config.DefaultJmsListenerContainerFactory import javax.jms.ConnectionFactory +@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") @Configuration(proxyBeanMethods = false) class MyJmsConfiguration { + @Bean - fun jmsListenerContainerFactory( - connectionFactory: ConnectionFactory?, - configurer: DefaultJmsListenerContainerFactoryConfigurer - ): DefaultJmsListenerContainerFactory { + fun jmsListenerContainerFactory(connectionFactory: ConnectionFactory?, + configurer: DefaultJmsListenerContainerFactoryConfigurer): DefaultJmsListenerContainerFactory { val listenerFactory = DefaultJmsListenerContainerFactory() configurer.configure(listenerFactory, connectionFactory) listenerFactory.setTransactionManager(null) listenerFactory.setSessionTransacted(false) return listenerFactory } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/propertiesandconfiguration/externalizeconfiguration/application/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/propertiesandconfiguration/externalizeconfiguration/application/MyApplication.kt index 8e70531d610..24d717a9965 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/propertiesandconfiguration/externalizeconfiguration/application/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/propertiesandconfiguration/externalizeconfiguration/application/MyApplication.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,10 +22,12 @@ import org.springframework.boot.autoconfigure.SpringBootApplication @SpringBootApplication object MyApplication { + @JvmStatic fun main(args: Array) { val application = SpringApplication(MyApplication::class.java) application.setBannerMode(Banner.Mode.OFF) application.run(*args) } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/propertiesandconfiguration/externalizeconfiguration/builder/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/propertiesandconfiguration/externalizeconfiguration/builder/MyApplication.kt index e5a484e1ad1..ac1cb1e3ddd 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/propertiesandconfiguration/externalizeconfiguration/builder/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/propertiesandconfiguration/externalizeconfiguration/builder/MyApplication.kt @@ -1,6 +1,5 @@ - /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,13 +20,13 @@ import org.springframework.boot.Banner import org.springframework.boot.builder.SpringApplicationBuilder object MyApplication { + @JvmStatic fun main(args: Array) { - // @formatter:off SpringApplicationBuilder() .bannerMode(Banner.Mode.OFF) .sources(MyApplication::class.java) .run(*args) - // @formatter:on } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/security/enablehttps/MySecurityConfig.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/security/enablehttps/MySecurityConfig.kt index b82bcf03580..0354fe386df 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/security/enablehttps/MySecurityConfig.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/security/enablehttps/MySecurityConfig.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,10 +23,12 @@ import org.springframework.security.web.SecurityFilterChain @Configuration class MySecurityConfig { + @Bean fun securityFilterChain(http: HttpSecurity): SecurityFilterChain { // Customize the application security ... http.requiresChannel().anyRequest().requiresSecure() return http.build() } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/springmvc/writejsonrestservice/MyController.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/springmvc/writejsonrestservice/MyController.kt index c2ac9f72250..13db5380dad 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/springmvc/writejsonrestservice/MyController.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/springmvc/writejsonrestservice/MyController.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,8 +21,10 @@ import org.springframework.web.bind.annotation.RestController @RestController class MyController { + @RequestMapping("/thing") fun thing(): MyThing { return MyThing() } + } diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/springmvc/writejsonrestservice/MyThing.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/springmvc/writejsonrestservice/MyThing.kt index 86de49749ca..ec95ef1e8b5 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/springmvc/writejsonrestservice/MyThing.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/springmvc/writejsonrestservice/MyThing.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.howto.springmvc.writejsonrestservice -class MyThing { -} \ No newline at end of file +class MyThing diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/springmvc/writexmlrestservice/MyThing.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/springmvc/writexmlrestservice/MyThing.kt index c8c5bdc4c90..cf42c67f926 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/springmvc/writexmlrestservice/MyThing.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/springmvc/writexmlrestservice/MyThing.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -20,5 +20,7 @@ import javax.xml.bind.annotation.XmlRootElement @XmlRootElement class MyThing { + var name: String? = null -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/testing/testcontainers/dynamicproperties/MyIntegrationTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/testing/testcontainers/dynamicproperties/MyIntegrationTests.kt index baa3047745f..5ac30bce134 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/testing/testcontainers/dynamicproperties/MyIntegrationTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/testing/testcontainers/dynamicproperties/MyIntegrationTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -27,17 +27,22 @@ import org.testcontainers.junit.jupiter.Testcontainers @SpringBootTest @Testcontainers internal class MyIntegrationTests { + @Test fun myTest() { // ... } companion object { + @Container var neo4j: Neo4jContainer<*> = Neo4jContainer("neo4j:4.2") + @DynamicPropertySource fun neo4jProperties(registry: DynamicPropertyRegistry) { - registry.add("spring.neo4j.uri") { neo4j.getBoltUrl() } + registry.add("spring.neo4j.uri") { neo4j.boltUrl } } + } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/testing/testcontainers/vanilla/MyIntegrationTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/testing/testcontainers/vanilla/MyIntegrationTests.kt index 23175846f99..41fa408739d 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/testing/testcontainers/vanilla/MyIntegrationTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/testing/testcontainers/vanilla/MyIntegrationTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -25,6 +25,7 @@ import org.testcontainers.junit.jupiter.Testcontainers @SpringBootTest @Testcontainers internal class MyIntegrationTests { + @Test fun myTest() { // ... @@ -34,4 +35,5 @@ internal class MyIntegrationTests { @Container var neo4j: Neo4jContainer<*> = Neo4jContainer("neo4j:4.2") } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/testing/withspringsecurity/MySecurityTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/testing/withspringsecurity/MySecurityTests.kt index d841f9c84ea..efbb12d1205 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/testing/withspringsecurity/MySecurityTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/testing/withspringsecurity/MySecurityTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -25,9 +25,11 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders @WebMvcTest(UserController::class) class MySecurityTests(@Autowired val mvc: MockMvc) { + @Test @WithMockUser(roles = ["ADMIN"]) fun requestProtectedUrlWithUser() { mvc.perform(MockMvcRequestBuilders.get("/")) } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/testing/withspringsecurity/UserController.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/testing/withspringsecurity/UserController.kt index b7217a2dc78..2e8c7a4ec7e 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/testing/withspringsecurity/UserController.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/testing/withspringsecurity/UserController.kt @@ -1,4 +1,19 @@ +/* + * Copyright 2012-2022 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.boot.docs.howto.testing.withspringsecurity -class UserController { -} \ No newline at end of file +class UserController diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/traditionaldeployment/convertexistingapplication/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/traditionaldeployment/convertexistingapplication/MyApplication.kt index 7d4fcc5dd0a..4c84f470be4 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/traditionaldeployment/convertexistingapplication/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/traditionaldeployment/convertexistingapplication/MyApplication.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,15 +23,18 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer @SpringBootApplication class MyApplication : SpringBootServletInitializer() { + override fun configure(application: SpringApplicationBuilder): SpringApplicationBuilder { // Customize the application or call application.sources(...) to add sources // Since our example is itself a @Configuration class (via @SpringBootApplication) // we actually do not need to override this method. return application } + } // tag::main[] fun main(args: Array) { runApplication(*args) -} // end::main[] +} +// end::main[] diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/traditionaldeployment/convertexistingapplication/both/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/traditionaldeployment/convertexistingapplication/both/MyApplication.kt index b0a693d0f85..4b027297c62 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/traditionaldeployment/convertexistingapplication/both/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/traditionaldeployment/convertexistingapplication/both/MyApplication.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,11 +23,13 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer @SpringBootApplication class MyApplication : SpringBootServletInitializer() { + override fun configure(builder: SpringApplicationBuilder): SpringApplicationBuilder { return customizerBuilder(builder) } companion object { + @JvmStatic fun main(args: Array) { customizerBuilder(SpringApplicationBuilder()).run(*args) @@ -36,5 +38,7 @@ class MyApplication : SpringBootServletInitializer() { private fun customizerBuilder(builder: SpringApplicationBuilder): SpringApplicationBuilder { return builder.sources(MyApplication::class.java).bannerMode(Banner.Mode.OFF) } + } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/traditionaldeployment/war/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/traditionaldeployment/war/MyApplication.kt index 6675a74515a..102edda4f84 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/traditionaldeployment/war/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/traditionaldeployment/war/MyApplication.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,11 +23,14 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer @SpringBootApplication class MyApplication : SpringBootServletInitializer() { + override fun configure(application: SpringApplicationBuilder): SpringApplicationBuilder { return application.sources(MyApplication::class.java) } + } fun main(args: Array) { runApplication(*args) } + diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/traditionaldeployment/weblogic/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/traditionaldeployment/weblogic/MyApplication.kt index f7ca917544c..61c1372007f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/traditionaldeployment/weblogic/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/traditionaldeployment/weblogic/MyApplication.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,4 +21,4 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer import org.springframework.web.WebApplicationInitializer @SpringBootApplication -class MyApplication : SpringBootServletInitializer(), WebApplicationInitializer \ No newline at end of file +class MyApplication : SpringBootServletInitializer(), WebApplicationInitializer diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/addservletfilterlistener/springbean/disable/Filter.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/addservletfilterlistener/springbean/disable/Filter.kt index cad480ea6a3..b8ef19043a4 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/addservletfilterlistener/springbean/disable/Filter.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/addservletfilterlistener/springbean/disable/Filter.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -18,4 +18,4 @@ package org.springframework.boot.docs.howto.webserver.addservletfilterlistener.s import javax.servlet.Filter -abstract class MyFilter : Filter \ No newline at end of file +abstract class MyFilter : Filter diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/addservletfilterlistener/springbean/disable/MyFilterConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/addservletfilterlistener/springbean/disable/MyFilterConfiguration.kt index f80243e479a..9fa75279631 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/addservletfilterlistener/springbean/disable/MyFilterConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/addservletfilterlistener/springbean/disable/MyFilterConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,10 +22,12 @@ import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) class MyFilterConfiguration { + @Bean fun registration(filter: MyFilter): FilterRegistrationBean { val registration = FilterRegistrationBean(filter) registration.isEnabled = false return registration } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/configure/MyTomcatWebServerCustomizer.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/configure/MyTomcatWebServerCustomizer.kt index a1d9647dd9e..1c9a63b6eec 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/configure/MyTomcatWebServerCustomizer.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/configure/MyTomcatWebServerCustomizer.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,7 +22,9 @@ import org.springframework.stereotype.Component @Component class MyTomcatWebServerCustomizer : WebServerFactoryCustomizer { + override fun customize(factory: TomcatServletWebServerFactory?) { // customize the factory here } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/createwebsocketendpointsusingserverendpoint/MyWebSocketConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/createwebsocketendpointsusingserverendpoint/MyWebSocketConfiguration.kt index 1e41428d873..b3bfa206c1e 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/createwebsocketendpointsusingserverendpoint/MyWebSocketConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/createwebsocketendpointsusingserverendpoint/MyWebSocketConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,8 +22,10 @@ import org.springframework.web.socket.server.standard.ServerEndpointExporter @Configuration(proxyBeanMethods = false) class MyWebSocketConfiguration { + @Bean fun serverEndpointExporter(): ServerEndpointExporter { return ServerEndpointExporter() } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/discoverport/MyWebIntegrationTests.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/discoverport/MyWebIntegrationTests.kt index f900938a2f4..627bd8b3fb9 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/discoverport/MyWebIntegrationTests.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/discoverport/MyWebIntegrationTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,9 +22,10 @@ import org.springframework.boot.web.server.LocalServerPort @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) class MyWebIntegrationTests { + @LocalServerPort var port = 0 // ... -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/enablemultipleconnectorsintomcat/MyTomcatConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/enablemultipleconnectorsintomcat/MyTomcatConfiguration.kt index 88ebd9f3949..7d6d01aaab4 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/enablemultipleconnectorsintomcat/MyTomcatConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/enablemultipleconnectorsintomcat/MyTomcatConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -27,6 +27,7 @@ import java.io.IOException @Configuration(proxyBeanMethods = false) class MyTomcatConfiguration { + @Bean fun sslConnectorCustomizer(): WebServerFactoryCustomizer { return WebServerFactoryCustomizer { tomcat: TomcatServletWebServerFactory -> @@ -56,4 +57,5 @@ class MyTomcatConfiguration { throw IllegalStateException("Fail to create ssl connector", ex) } } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/enablemultiplelistenersinundertow/MyUndertowConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/enablemultiplelistenersinundertow/MyUndertowConfiguration.kt index d22efe9acd1..66977dc15a4 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/enablemultiplelistenersinundertow/MyUndertowConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/enablemultiplelistenersinundertow/MyUndertowConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -25,6 +25,7 @@ import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) class MyUndertowConfiguration { + @Bean fun undertowListenerCustomizer(): WebServerFactoryCustomizer { return WebServerFactoryCustomizer { factory: UndertowServletWebServerFactory -> @@ -36,4 +37,5 @@ class MyUndertowConfiguration { private fun addHttpListener(builder: Undertow.Builder): Undertow.Builder { return builder.addHttpListener(8080, "0.0.0.0") } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/usetomcatlegacycookieprocessor/MyLegacyCookieProcessorConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/usetomcatlegacycookieprocessor/MyLegacyCookieProcessorConfiguration.kt index ea054171b78..86bb0125d62 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/usetomcatlegacycookieprocessor/MyLegacyCookieProcessorConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/webserver/usetomcatlegacycookieprocessor/MyLegacyCookieProcessorConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -26,6 +26,7 @@ import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) class MyLegacyCookieProcessorConfiguration { + @Bean fun cookieProcessorCustomizer(): WebServerFactoryCustomizer { return WebServerFactoryCustomizer { factory: TomcatServletWebServerFactory -> @@ -35,4 +36,5 @@ class MyLegacyCookieProcessorConfiguration { }) } } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/caching/MyMathService.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/caching/MyMathService.kt index 532b661444e..0332bc40981 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/caching/MyMathService.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/caching/MyMathService.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -19,11 +19,13 @@ package org.springframework.boot.docs.io.caching import org.springframework.cache.annotation.Cacheable import org.springframework.stereotype.Component +@Suppress("UNUSED_PARAMETER") @Component class MyMathService { + @Cacheable("piDecimals") fun computePiDecimal(precision: Int): Int { - /**/ - return 0 + /**/ return 0 } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/caching/provider/MyCacheManagerConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/caching/provider/MyCacheManagerConfiguration.kt index 133379fb353..4975de209da 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/caching/provider/MyCacheManagerConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/caching/provider/MyCacheManagerConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,10 +23,12 @@ import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) class MyCacheManagerConfiguration { + @Bean fun cacheManagerCustomizer(): CacheManagerCustomizer { - return CacheManagerCustomizer { cacheManager: ConcurrentMapCacheManager -> + return CacheManagerCustomizer { cacheManager -> cacheManager.isAllowNullValues = false } } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/caching/provider/couchbase/MyCouchbaseCacheManagerConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/caching/provider/couchbase/MyCouchbaseCacheManagerConfiguration.kt index 75356203cb2..4d992f91d02 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/caching/provider/couchbase/MyCouchbaseCacheManagerConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/caching/provider/couchbase/MyCouchbaseCacheManagerConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -20,15 +20,14 @@ import org.springframework.boot.autoconfigure.cache.CouchbaseCacheManagerBuilder import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.data.couchbase.cache.CouchbaseCacheConfiguration -import org.springframework.data.couchbase.cache.CouchbaseCacheManager.CouchbaseCacheManagerBuilder import java.time.Duration @Configuration(proxyBeanMethods = false) class MyCouchbaseCacheManagerConfiguration { + @Bean fun myCouchbaseCacheManagerBuilderCustomizer(): CouchbaseCacheManagerBuilderCustomizer { - // @formatter:off - return CouchbaseCacheManagerBuilderCustomizer { builder: CouchbaseCacheManagerBuilder -> + return CouchbaseCacheManagerBuilderCustomizer { builder -> builder .withCacheConfiguration( "cache1", CouchbaseCacheConfiguration @@ -39,6 +38,6 @@ class MyCouchbaseCacheManagerConfiguration { .defaultCacheConfig().entryExpiry(Duration.ofMinutes(1)) ) } - // @formatter:on } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/caching/provider/redis/MyRedisCacheManagerConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/caching/provider/redis/MyRedisCacheManagerConfiguration.kt index c67b9ba7103..38943347fc8 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/caching/provider/redis/MyRedisCacheManagerConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/caching/provider/redis/MyRedisCacheManagerConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -20,15 +20,14 @@ import org.springframework.boot.autoconfigure.cache.RedisCacheManagerBuilderCust import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.data.redis.cache.RedisCacheConfiguration -import org.springframework.data.redis.cache.RedisCacheManager.RedisCacheManagerBuilder import java.time.Duration @Configuration(proxyBeanMethods = false) class MyRedisCacheManagerConfiguration { + @Bean fun myRedisCacheManagerBuilderCustomizer(): RedisCacheManagerBuilderCustomizer { - // @formatter:off - return RedisCacheManagerBuilderCustomizer { builder: RedisCacheManagerBuilder -> + return RedisCacheManagerBuilderCustomizer { builder -> builder .withCacheConfiguration( "cache1", RedisCacheConfiguration @@ -39,6 +38,6 @@ class MyRedisCacheManagerConfiguration { .defaultCacheConfig().entryTtl(Duration.ofMinutes(1)) ) } - // @formatter:on } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/jta/mixingxaandnonxaconnections/nonxa/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/jta/mixingxaandnonxaconnections/nonxa/MyBean.kt index 6115e6dbcce..f64c8c2b920 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/jta/mixingxaandnonxaconnections/nonxa/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/jta/mixingxaandnonxaconnections/nonxa/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -19,4 +19,5 @@ package org.springframework.boot.docs.io.jta.mixingxaandnonxaconnections.nonxa import org.springframework.beans.factory.annotation.Qualifier import javax.jms.ConnectionFactory +@Suppress("UNUSED_PARAMETER") class MyBean(@Qualifier("nonXaJmsConnectionFactory") connectionFactory: ConnectionFactory?) diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/jta/mixingxaandnonxaconnections/primary/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/jta/mixingxaandnonxaconnections/primary/MyBean.kt index 13aecd531ce..d51ea531696 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/jta/mixingxaandnonxaconnections/primary/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/jta/mixingxaandnonxaconnections/primary/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -18,4 +18,5 @@ package org.springframework.boot.docs.io.jta.mixingxaandnonxaconnections.primary import javax.jms.ConnectionFactory +@Suppress("UNUSED_PARAMETER") class MyBean(connectionFactory: ConnectionFactory?) diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/jta/mixingxaandnonxaconnections/xa/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/jta/mixingxaandnonxaconnections/xa/MyBean.kt index 3634149b3ba..ba8d239af2f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/jta/mixingxaandnonxaconnections/xa/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/jta/mixingxaandnonxaconnections/xa/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -19,4 +19,5 @@ package org.springframework.boot.docs.io.jta.mixingxaandnonxaconnections.xa import org.springframework.beans.factory.annotation.Qualifier import javax.jms.ConnectionFactory +@Suppress("UNUSED_PARAMETER") class MyBean(@Qualifier("xaJmsConnectionFactory") connectionFactory: ConnectionFactory?) diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/quartz/MySampleJob.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/quartz/MySampleJob.kt index 551cb0cd7cc..334f5aa73d1 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/quartz/MySampleJob.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/quartz/MySampleJob.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -20,11 +20,13 @@ import org.quartz.JobExecutionContext import org.springframework.scheduling.quartz.QuartzJobBean class MySampleJob : QuartzJobBean() { + // @fold:on // fields ... private var myService: MyService? = null - private var name: String? = null + private var name: String? = null // @fold:off + // Inject "MyService" bean fun setMyService(myService: MyService?) { this.myService = myService @@ -38,4 +40,5 @@ class MySampleJob : QuartzJobBean() { override fun executeInternal(context: JobExecutionContext) { myService!!.someMethod(context.fireTime, name) } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/quartz/MyService.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/quartz/MyService.kt index 73e27984f8a..4cdcb814bae 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/quartz/MyService.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/quartz/MyService.kt @@ -1,7 +1,26 @@ +/* + * Copyright 2012-2022 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.boot.docs.io.quartz -import java.util.* +import java.util.Date +@Suppress("UNUSED_PARAMETER") class MyService { + fun someMethod(date: Date?, name: String?) {} -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/resttemplate/Details.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/resttemplate/Details.kt index 56d0fc83d29..7d8a0f2cd4c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/resttemplate/Details.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/resttemplate/Details.kt @@ -1,4 +1,19 @@ +/* + * Copyright 2012-2022 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.boot.docs.io.restclient.resttemplate -class Details { -} \ No newline at end of file +class Details diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/resttemplate/MyService.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/resttemplate/MyService.kt index ee95b16de1d..adc6f6dbced 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/resttemplate/MyService.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/resttemplate/MyService.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -20,8 +20,10 @@ import org.springframework.boot.web.client.RestTemplateBuilder import org.springframework.stereotype.Service import org.springframework.web.client.RestTemplate +@Suppress("UNUSED_PARAMETER") @Service class MyService(restTemplateBuilder: RestTemplateBuilder) { + private val restTemplate: RestTemplate init { @@ -32,6 +34,7 @@ class MyService(restTemplateBuilder: RestTemplateBuilder) { return restTemplate.getForObject( "/{name}/details", Details::class.java, name - ) + )!! } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/resttemplate/customization/MyRestTemplateBuilderConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/resttemplate/customization/MyRestTemplateBuilderConfiguration.kt index 4c9c1f02af8..cbf8edfe543 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/resttemplate/customization/MyRestTemplateBuilderConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/resttemplate/customization/MyRestTemplateBuilderConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,9 +24,11 @@ import java.time.Duration @Configuration(proxyBeanMethods = false) class MyRestTemplateBuilderConfiguration { + @Bean fun restTemplateBuilder(configurer: RestTemplateBuilderConfigurer): RestTemplateBuilder { return configurer.configure(RestTemplateBuilder()).setConnectTimeout(Duration.ofSeconds(5)) .setReadTimeout(Duration.ofSeconds(2)) } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/resttemplate/customization/MyRestTemplateCustomizer.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/resttemplate/customization/MyRestTemplateCustomizer.kt index 4f37797f0f0..c6379ba28f7 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/resttemplate/customization/MyRestTemplateCustomizer.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/resttemplate/customization/MyRestTemplateCustomizer.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -30,6 +30,7 @@ import org.springframework.web.client.RestTemplate import kotlin.jvm.Throws class MyRestTemplateCustomizer : RestTemplateCustomizer { + override fun customize(restTemplate: RestTemplate) { val routePlanner: HttpRoutePlanner = CustomRoutePlanner(HttpHost("proxy.example.com")) val httpClient: HttpClient = HttpClientBuilder.create().setRoutePlanner(routePlanner).build() @@ -37,11 +38,15 @@ class MyRestTemplateCustomizer : RestTemplateCustomizer { } internal class CustomRoutePlanner(proxy: HttpHost?) : DefaultProxyRoutePlanner(proxy) { + @Throws(HttpException::class) public override fun determineProxy(target: HttpHost, request: HttpRequest, context: HttpContext): HttpHost? { - return if (target.hostName == "192.168.0.5") { - null - } else super.determineProxy(target, request, context) + if (target.hostName == "192.168.0.5") { + return null + } + return super.determineProxy(target, request, context) } + } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/webclient/MyService.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/webclient/MyService.kt index a0e9711e72e..6caf7873206 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/webclient/MyService.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/restclient/webclient/MyService.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,6 +23,7 @@ import reactor.core.publisher.Mono @Service class MyService(webClientBuilder: WebClient.Builder) { + private val webClient: WebClient init { @@ -34,4 +35,6 @@ class MyService(webClientBuilder: WebClient.Builder) { Relationship.Details::class.java ) } + } + diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/validation/Archive.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/validation/Archive.kt index 30426f71fe0..76c16b157e0 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/validation/Archive.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/validation/Archive.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.io.validation -class Archive { -} \ No newline at end of file +class Archive diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/validation/Author.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/validation/Author.kt index 7d9b486fc07..462b73008c9 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/validation/Author.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/validation/Author.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.io.validation -class Author { -} \ No newline at end of file +class Author diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/validation/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/validation/MyBean.kt index 71670af408a..eebfccacc79 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/validation/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/validation/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -20,10 +20,13 @@ import org.springframework.stereotype.Service import org.springframework.validation.annotation.Validated import javax.validation.constraints.Size +@Suppress("UNUSED_PARAMETER") @Service @Validated class MyBean { + fun findByCodeAndAuthor(code: @Size(min = 8, max = 10) String?, author: Author?): Archive? { return null } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/webservices/template/MyService.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/webservices/template/MyService.kt index b49261dff23..49470945f37 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/webservices/template/MyService.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/webservices/template/MyService.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,6 +23,7 @@ import org.springframework.ws.soap.client.core.SoapActionCallback @Service class MyService(webServiceTemplateBuilder: WebServiceTemplateBuilder) { + private val webServiceTemplate: WebServiceTemplate init { @@ -35,4 +36,5 @@ class MyService(webServiceTemplateBuilder: WebServiceTemplateBuilder) { SoapActionCallback("https://ws.example.com/action") ) as SomeResponse } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/webservices/template/MyWebServiceTemplateConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/webservices/template/MyWebServiceTemplateConfiguration.kt index 2cea17d2a09..c9a86da99df 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/webservices/template/MyWebServiceTemplateConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/webservices/template/MyWebServiceTemplateConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -25,14 +25,14 @@ import java.time.Duration @Configuration(proxyBeanMethods = false) class MyWebServiceTemplateConfiguration { + @Bean fun webServiceTemplate(builder: WebServiceTemplateBuilder): WebServiceTemplate { - // @formatter:off val sender = HttpWebServiceMessageSenderBuilder() .setConnectTimeout(Duration.ofSeconds(5)) .setReadTimeout(Duration.ofSeconds(2)) .build() return builder.messageSenders(sender).build() - // @formatter:on } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/webservices/template/SomeRequest.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/webservices/template/SomeRequest.kt index 49e97d48462..b110ee57b5e 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/webservices/template/SomeRequest.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/webservices/template/SomeRequest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.io.webservices.template -class SomeRequest { -} \ No newline at end of file +class SomeRequest diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/webservices/template/SomeResponse.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/webservices/template/SomeResponse.kt index 74833dab986..43799b7cb74 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/webservices/template/SomeResponse.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/io/webservices/template/SomeResponse.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.io.webservices.template -class SomeResponse { -} \ No newline at end of file +class SomeResponse diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/amqp/receiving/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/amqp/receiving/MyBean.kt index 2eed9286d38..91f00f5ef07 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/amqp/receiving/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/amqp/receiving/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -19,10 +19,14 @@ package org.springframework.boot.docs.messaging.amqp.receiving import org.springframework.amqp.rabbit.annotation.RabbitListener import org.springframework.stereotype.Component +@Suppress("UNUSED_PARAMETER") @Component class MyBean { + @RabbitListener(queues = ["someQueue"]) fun processMessage(content: String?) { // ... } + } + diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/amqp/receiving/custom/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/amqp/receiving/custom/MyBean.kt index 34bd91463a0..7934b421e4a 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/amqp/receiving/custom/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/amqp/receiving/custom/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -19,10 +19,13 @@ package org.springframework.boot.docs.messaging.amqp.receiving.custom import org.springframework.amqp.rabbit.annotation.RabbitListener import org.springframework.stereotype.Component +@Suppress("UNUSED_PARAMETER") @Component class MyBean { + @RabbitListener(queues = ["someQueue"], containerFactory = "myFactory") fun processMessage(content: String?) { // ... } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/amqp/receiving/custom/MyMessageConverter.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/amqp/receiving/custom/MyMessageConverter.kt index 14553b96748..f76819aea35 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/amqp/receiving/custom/MyMessageConverter.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/amqp/receiving/custom/MyMessageConverter.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,6 +21,7 @@ import org.springframework.amqp.core.MessageProperties import org.springframework.amqp.support.converter.MessageConverter internal class MyMessageConverter : MessageConverter { + override fun toMessage(`object`: Any, messageProperties: MessageProperties): Message? { return null } @@ -28,4 +29,5 @@ internal class MyMessageConverter : MessageConverter { override fun fromMessage(message: Message): Any? { return null } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/amqp/receiving/custom/MyRabbitConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/amqp/receiving/custom/MyRabbitConfiguration.kt index 8b3df1f858f..af0e01da389 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/amqp/receiving/custom/MyRabbitConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/amqp/receiving/custom/MyRabbitConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,16 +24,18 @@ import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) class MyRabbitConfiguration { + @Bean fun myFactory(configurer: SimpleRabbitListenerContainerFactoryConfigurer): SimpleRabbitListenerContainerFactory { val factory = SimpleRabbitListenerContainerFactory() - val connectionFactory = customConnectionFactory + val connectionFactory = getCustomConnectionFactory() configurer.configure(factory, connectionFactory) factory.setMessageConverter(MyMessageConverter()) return factory } - /**/ - private val customConnectionFactory: ConnectionFactory? - get() = /**/ null + fun getCustomConnectionFactory() : ConnectionFactory? { + return /**/ null + } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/amqp/sending/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/amqp/sending/MyBean.kt index a099118fd9a..df6f0a52580 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/amqp/sending/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/amqp/sending/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,6 +22,7 @@ import org.springframework.stereotype.Component @Component class MyBean(private val amqpAdmin: AmqpAdmin, private val amqpTemplate: AmqpTemplate) { + // @fold:on // ... fun someMethod() { amqpAdmin.getQueueInfo("someQueue") @@ -29,5 +30,7 @@ class MyBean(private val amqpAdmin: AmqpAdmin, private val amqpTemplate: AmqpTem fun someOtherMethod() { amqpTemplate.convertAndSend("hello") - } // @fold:off + } + // @fold:off + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/jms/receiving/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/jms/receiving/MyBean.kt index 08aa92e5c6f..3c54323d5d8 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/jms/receiving/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/jms/receiving/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -19,10 +19,13 @@ package org.springframework.boot.docs.messaging.jms.receiving import org.springframework.jms.annotation.JmsListener import org.springframework.stereotype.Component +@Suppress("UNUSED_PARAMETER") @Component class MyBean { + @JmsListener(destination = "someQueue") fun processMessage(content: String?) { // ... } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/jms/receiving/custom/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/jms/receiving/custom/MyBean.kt index d5d291adb61..77bc59c30a3 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/jms/receiving/custom/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/jms/receiving/custom/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -19,10 +19,13 @@ package org.springframework.boot.docs.messaging.jms.receiving.custom import org.springframework.jms.annotation.JmsListener import org.springframework.stereotype.Component +@Suppress("UNUSED_PARAMETER") @Component class MyBean { + @JmsListener(destination = "someQueue", containerFactory = "myFactory") fun processMessage(content: String?) { // ... } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/jms/receiving/custom/MyJmsConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/jms/receiving/custom/MyJmsConfiguration.kt index dbdfeb0f471..09334529588 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/jms/receiving/custom/MyJmsConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/jms/receiving/custom/MyJmsConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,15 +24,18 @@ import javax.jms.ConnectionFactory @Configuration(proxyBeanMethods = false) class MyJmsConfiguration { + @Bean fun myFactory(configurer: DefaultJmsListenerContainerFactoryConfigurer): DefaultJmsListenerContainerFactory { val factory = DefaultJmsListenerContainerFactory() - val connectionFactory = customConnectionFactory + val connectionFactory = getCustomConnectionFactory() configurer.configure(factory, connectionFactory) factory.setMessageConverter(MyMessageConverter()) return factory } - private val customConnectionFactory: ConnectionFactory? - get() =null -} \ No newline at end of file + fun getCustomConnectionFactory() : ConnectionFactory? { + return /**/ null + } + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/jms/receiving/custom/MyMessageConverter.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/jms/receiving/custom/MyMessageConverter.kt index 0d92ae03c20..2d55421b29b 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/jms/receiving/custom/MyMessageConverter.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/jms/receiving/custom/MyMessageConverter.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -20,8 +20,8 @@ import org.springframework.jms.support.converter.MessageConverter import javax.jms.Message import javax.jms.Session - internal class MyMessageConverter : MessageConverter { + override fun toMessage(`object`: Any, session: Session): Message? { return null } @@ -29,4 +29,5 @@ internal class MyMessageConverter : MessageConverter { override fun fromMessage(message: Message): Any? { return null } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/jms/sending/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/jms/sending/MyBean.kt index 7d5b2eec358..0d36c7e3570 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/jms/sending/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/jms/sending/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,8 +21,11 @@ import org.springframework.stereotype.Component @Component class MyBean(private val jmsTemplate: JmsTemplate) { + // @fold:on // ... fun someMethod() { jmsTemplate.convertAndSend("hello") - } // @fold:off -} \ No newline at end of file + } + // @fold:off + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/kafka/embedded/annotation/MyTest.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/kafka/embedded/annotation/MyTest.kt index 708bebc3971..cc5577d91fb 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/kafka/embedded/annotation/MyTest.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/kafka/embedded/annotation/MyTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,5 +21,8 @@ import org.springframework.kafka.test.context.EmbeddedKafka @SpringBootTest @EmbeddedKafka(topics = ["someTopic"], bootstrapServersProperty = "spring.kafka.bootstrap-servers") -class MyTest { // ... -} \ No newline at end of file +class MyTest { + + // ... + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/kafka/embedded/property/MyTest.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/kafka/embedded/property/MyTest.kt index 38dc0c9bdbd..7b9252992c0 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/kafka/embedded/property/MyTest.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/kafka/embedded/property/MyTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,9 +21,11 @@ import org.springframework.kafka.test.EmbeddedKafkaBroker @SpringBootTest object MyTest { + // tag::code[] init { System.setProperty(EmbeddedKafkaBroker.BROKER_LIST_PROPERTY, "spring.kafka.bootstrap-servers") } // end::code[] + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/kafka/receiving/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/kafka/receiving/MyBean.kt index ff4a3af7bf4..35eb62e2417 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/kafka/receiving/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/kafka/receiving/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -19,10 +19,14 @@ package org.springframework.boot.docs.messaging.kafka.receiving import org.springframework.kafka.annotation.KafkaListener import org.springframework.stereotype.Component +@Suppress("UNUSED_PARAMETER") @Component class MyBean { + @KafkaListener(topics = ["someTopic"]) fun processMessage(content: String?) { // ... } + } + diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/kafka/sending/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/kafka/sending/MyBean.kt index 154b73b7e8a..09fce38169f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/kafka/sending/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/kafka/sending/MyBean.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,8 +21,11 @@ import org.springframework.stereotype.Component @Component class MyBean(private val kafkaTemplate: KafkaTemplate) { + // @fold:on // ... fun someMethod() { kafkaTemplate.send("someTopic", "Hello") - } // @fold:off -} \ No newline at end of file + } + // @fold:off + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/kafka/streams/MyKafkaStreamsConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/kafka/streams/MyKafkaStreamsConfiguration.kt index cb4cbbef68c..50fa5565668 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/kafka/streams/MyKafkaStreamsConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/kafka/streams/MyKafkaStreamsConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -26,22 +26,20 @@ import org.springframework.context.annotation.Configuration import org.springframework.kafka.annotation.EnableKafkaStreams import org.springframework.kafka.support.serializer.JsonSerde +@Suppress("UNUSED_PARAMETER") @Configuration(proxyBeanMethods = false) @EnableKafkaStreams class MyKafkaStreamsConfiguration { + @Bean fun kStream(streamsBuilder: StreamsBuilder): KStream { val stream = streamsBuilder.stream("ks1In") - stream.map { key: Int, value: String -> - uppercaseValue( - key, - value - ) - }.to("ks1Out", Produced.with(Serdes.Integer(), JsonSerde())) + stream.map(this::uppercaseValue).to("ks1Out", Produced.with(Serdes.Integer(), JsonSerde())) return stream } private fun uppercaseValue(key: Int, value: String): KeyValue { - return KeyValue(key, value.toUpperCase()) + return KeyValue(key, value.uppercase()) } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/rsocket/requester/MyService.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/rsocket/requester/MyService.kt index caa2fd552ef..a268d92c9d3 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/rsocket/requester/MyService.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/rsocket/requester/MyService.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,6 +22,7 @@ import reactor.core.publisher.Mono @Service class MyService(rsocketRequesterBuilder: RSocketRequester.Builder) { + private val rsocketRequester: RSocketRequester init { @@ -33,4 +34,5 @@ class MyService(rsocketRequesterBuilder: RSocketRequester.Builder) { User::class.java ) } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/rsocket/requester/User.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/rsocket/requester/User.kt index 2117c187630..be2ddbc92cc 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/rsocket/requester/User.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/messaging/rsocket/requester/User.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.messaging.rsocket.requester -class User { -} \ No newline at end of file +class User diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/autoconfiguration/disablingspecific/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/autoconfiguration/disablingspecific/MyApplication.kt index 22e5dd80b5d..8f92f5d3265 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/autoconfiguration/disablingspecific/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/autoconfiguration/disablingspecific/MyApplication.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -20,6 +20,4 @@ import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration @SpringBootApplication(exclude = [DataSourceAutoConfiguration::class]) -class MyApplication { - -} \ No newline at end of file +class MyApplication diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/devtools/restart/disable/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/devtools/restart/disable/MyApplication.kt new file mode 100644 index 00000000000..8454f1ae10e --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/devtools/restart/disable/MyApplication.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2012-2022 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.using.devtools.restart.disable + +import org.springframework.boot.SpringApplication +import org.springframework.boot.autoconfigure.SpringBootApplication + +@SpringBootApplication +object MyApplication { + + @JvmStatic + fun main(args: Array) { + System.setProperty("spring.devtools.restart.enabled", "false") + SpringApplication.run(MyApplication::class.java, *args) + } + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/springbeansanddependencyinjection/multipleconstructors/MyAccountService.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/springbeansanddependencyinjection/multipleconstructors/MyAccountService.kt index 79be434f995..6a1557846ea 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/springbeansanddependencyinjection/multipleconstructors/MyAccountService.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/springbeansanddependencyinjection/multipleconstructors/MyAccountService.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,7 +22,9 @@ import java.io.PrintStream @Service class MyAccountService : AccountService { + private val riskAssessor: RiskAssessor + private val out: PrintStream @Autowired @@ -35,5 +37,7 @@ class MyAccountService : AccountService { this.riskAssessor = riskAssessor this.out = out } + // ... -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/springbeansanddependencyinjection/singleconstructor/MyAccountService.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/springbeansanddependencyinjection/singleconstructor/MyAccountService.kt index 7af5eb09598..b9f97037c55 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/springbeansanddependencyinjection/singleconstructor/MyAccountService.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/springbeansanddependencyinjection/singleconstructor/MyAccountService.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -19,4 +19,4 @@ package org.springframework.boot.docs.using.springbeansanddependencyinjection.si import org.springframework.stereotype.Service @Service -class MyAccountService(private val riskAssessor: RiskAssessor) : AccountService \ No newline at end of file +class MyAccountService(private val riskAssessor: RiskAssessor) : AccountService diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/structuringyourcode/locatingthemainclass/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/structuringyourcode/locatingthemainclass/MyApplication.kt index 4a60443cd84..8220b4fb336 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/structuringyourcode/locatingthemainclass/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/structuringyourcode/locatingthemainclass/MyApplication.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,4 +24,4 @@ class MyApplication fun main(args: Array) { runApplication(*args) -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/usingthespringbootapplicationannotation/individualannotations/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/usingthespringbootapplicationannotation/individualannotations/MyApplication.kt index fafa55ad60e..1373718cb6d 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/usingthespringbootapplicationannotation/individualannotations/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/usingthespringbootapplicationannotation/individualannotations/MyApplication.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,12 +24,9 @@ import org.springframework.context.annotation.Import @SpringBootConfiguration(proxyBeanMethods = false) @EnableAutoConfiguration -@Import( - SomeConfiguration::class, - AnotherConfiguration::class -) +@Import(SomeConfiguration::class, AnotherConfiguration::class) class MyApplication fun main(args: Array) { runApplication(*args) -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/usingthespringbootapplicationannotation/springapplication/MyApplication.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/usingthespringbootapplicationannotation/springapplication/MyApplication.kt index be017e8cce0..d4f9bb15c2c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/usingthespringbootapplicationannotation/springapplication/MyApplication.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/using/usingthespringbootapplicationannotation/springapplication/MyApplication.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -19,10 +19,10 @@ package org.springframework.boot.docs.using.usingthespringbootapplicationannotat import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication -@SpringBootApplication // same as @SpringBootConfiguration @EnableAutoConfiguration - // @ComponentScan +// same as @SpringBootConfiguration @EnableAutoConfiguration @ComponentScan +@SpringBootApplication class MyApplication fun main(args: Array) { runApplication(*args) -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/graphql/runtimewiring/GreetingController.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/graphql/runtimewiring/GreetingController.kt new file mode 100644 index 00000000000..0e410ef66cd --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/graphql/runtimewiring/GreetingController.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2012-2022 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.web.graphql.runtimewiring; + +import org.springframework.graphql.data.method.annotation.Argument +import org.springframework.graphql.data.method.annotation.QueryMapping +import org.springframework.stereotype.Controller + +@Controller +class GreetingController { + + @QueryMapping + fun greeting(@Argument name: String): String { + return "Hello, $name!" + } + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/Customer.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/Customer.kt index e3a88d4ff41..68e9b6f4bdd 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/Customer.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/Customer.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.web.reactive.webflux -class Customer { -} \ No newline at end of file +class Customer diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/CustomerRepository.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/CustomerRepository.kt index b4d2a229a6b..9a313227022 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/CustomerRepository.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/CustomerRepository.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -19,7 +19,8 @@ package org.springframework.boot.docs.web.reactive.webflux import org.springframework.data.repository.reactive.ReactiveCrudRepository import reactor.core.publisher.Flux -interface CustomerRepository : - ReactiveCrudRepository { +interface CustomerRepository : ReactiveCrudRepository { + fun findByUser(user: User?): Flux? -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/MyRestController.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/MyRestController.kt index fe94d1c1ea2..68b154c6ac1 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/MyRestController.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/MyRestController.kt @@ -1,13 +1,33 @@ +/* + * Copyright 2012-2022 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.boot.docs.web.reactive.webflux -import org.springframework.web.bind.annotation.* +import org.springframework.web.bind.annotation.DeleteMapping +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController import reactor.core.publisher.Flux import reactor.core.publisher.Mono - @RestController @RequestMapping("/users") class MyRestController(private val userRepository: UserRepository, private val customerRepository: CustomerRepository) { + @GetMapping("/{user}") fun getUser(@PathVariable userId: Long): Mono { return userRepository.findById(userId) @@ -16,9 +36,7 @@ class MyRestController(private val userRepository: UserRepository, private val c @GetMapping("/{user}/customers") fun getUserCustomers(@PathVariable userId: Long): Flux { return userRepository.findById(userId).flatMapMany { user: User? -> - customerRepository.findByUser( - user - ) + customerRepository.findByUser(user) } } @@ -26,4 +44,6 @@ class MyRestController(private val userRepository: UserRepository, private val c fun deleteUser(@PathVariable userId: Long) { userRepository.deleteById(userId) } + } + diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/MyRoutingConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/MyRoutingConfiguration.kt index 9a6f455aa5b..524d2e31fef 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/MyRoutingConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/MyRoutingConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -19,36 +19,26 @@ package org.springframework.boot.docs.web.reactive.webflux import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.http.MediaType -import org.springframework.web.reactive.function.server.* +import org.springframework.web.reactive.function.server.RequestPredicates.DELETE +import org.springframework.web.reactive.function.server.RequestPredicates.GET +import org.springframework.web.reactive.function.server.RequestPredicates.accept +import org.springframework.web.reactive.function.server.RouterFunction +import org.springframework.web.reactive.function.server.RouterFunctions +import org.springframework.web.reactive.function.server.ServerResponse @Configuration(proxyBeanMethods = false) class MyRoutingConfiguration { + @Bean fun monoRouterFunction(userHandler: MyUserHandler): RouterFunction { - // @formatter:off return RouterFunctions.route( - RequestPredicates.GET("/{user}").and(ACCEPT_JSON), - HandlerFunction { request: ServerRequest? -> - userHandler.getUser( - request - ) - }).andRoute( - RequestPredicates.GET("/{user}/customers").and(ACCEPT_JSON), - HandlerFunction { request: ServerRequest? -> - userHandler.getUserCustomers( - request - ) - }).andRoute( - RequestPredicates.DELETE("/{user}").and(ACCEPT_JSON), - HandlerFunction { request: ServerRequest? -> - userHandler.deleteUser( - request - ) - }) - // @formatter:on + GET("/{user}").and(ACCEPT_JSON), userHandler::getUser).andRoute( + GET("/{user}/customers").and(ACCEPT_JSON), userHandler::getUserCustomers).andRoute( + DELETE("/{user}").and(ACCEPT_JSON), userHandler::deleteUser) } companion object { - private val ACCEPT_JSON = RequestPredicates.accept(MediaType.APPLICATION_JSON) + private val ACCEPT_JSON = accept(MediaType.APPLICATION_JSON) } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/MyUserHandler.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/MyUserHandler.kt index 4d3c6194a39..1a768d9ef3c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/MyUserHandler.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/MyUserHandler.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,8 +21,10 @@ import org.springframework.web.reactive.function.server.ServerRequest import org.springframework.web.reactive.function.server.ServerResponse import reactor.core.publisher.Mono +@Suppress("UNUSED_PARAMETER") @Component class MyUserHandler { + fun getUser(request: ServerRequest?): Mono { return ServerResponse.ok().build() } @@ -34,4 +36,5 @@ class MyUserHandler { fun deleteUser(request: ServerRequest?): Mono { return ServerResponse.ok().build() } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/User.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/User.kt index 354622e307d..dc684b3514f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/User.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/User.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,6 +17,8 @@ package org.springframework.boot.docs.web.reactive.webflux class User { + val customers: List? get() = null -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/UserRepository.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/UserRepository.kt index e6cfc76fbf8..f8340c04dab 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/UserRepository.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/UserRepository.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -18,5 +18,4 @@ package org.springframework.boot.docs.web.reactive.webflux import org.springframework.data.repository.reactive.ReactiveCrudRepository -interface UserRepository : - ReactiveCrudRepository \ No newline at end of file +interface UserRepository : ReactiveCrudRepository diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/errorhandling/MyErrorWebExceptionHandler.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/errorhandling/MyErrorWebExceptionHandler.kt index a34d6f4a8f5..d252b81555e 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/errorhandling/MyErrorWebExceptionHandler.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/errorhandling/MyErrorWebExceptionHandler.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -29,24 +29,13 @@ import org.springframework.web.reactive.function.server.ServerRequest import org.springframework.web.reactive.function.server.ServerResponse import reactor.core.publisher.Mono +@Suppress("UNUSED_PARAMETER") @Component -class MyErrorWebExceptionHandler( - errorAttributes: ErrorAttributes?, resources: WebProperties.Resources?, - applicationContext: ApplicationContext? -) : - AbstractErrorWebExceptionHandler(errorAttributes, resources, applicationContext) { +class MyErrorWebExceptionHandler(errorAttributes: ErrorAttributes?, resources: WebProperties.Resources?, + applicationContext: ApplicationContext?) : AbstractErrorWebExceptionHandler(errorAttributes, resources, applicationContext) { + override fun getRoutingFunction(errorAttributes: ErrorAttributes): RouterFunction { - return RouterFunctions.route( - { request: ServerRequest -> - acceptsXml( - request - ) - } - ) { request: ServerRequest? -> - handleErrorAsXml( - request - ) - } + return RouterFunctions.route(this::acceptsXml, this::handleErrorAsXml) } private fun acceptsXml(request: ServerRequest): Boolean { @@ -58,4 +47,6 @@ class MyErrorWebExceptionHandler( // ... additional builder calls return builder.build() } + } + diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/errorhandling/MyExceptionHandlingController.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/errorhandling/MyExceptionHandlingController.kt index 33356d36168..26dfa251d46 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/errorhandling/MyExceptionHandlingController.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/errorhandling/MyExceptionHandlingController.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,8 +23,10 @@ import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.reactive.result.view.Rendering import org.springframework.web.server.ServerWebExchange +@Suppress("UNUSED_PARAMETER") @Controller class MyExceptionHandlingController { + @GetMapping("/profile") fun userProfile(): Rendering { // ... @@ -34,6 +36,7 @@ class MyExceptionHandlingController { @ExceptionHandler(IllegalStateException::class) fun handleIllegalState(exchange: ServerWebExchange, exc: IllegalStateException): Rendering { exchange.attributes.putIfAbsent(ErrorAttributes.ERROR_ATTRIBUTE, exc) - return Rendering.view("errorView").modelAttribute("message", exc.message).build() + return Rendering.view("errorView").modelAttribute("message", exc.message ?: "").build() } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/httpcodecs/MyCodecsConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/httpcodecs/MyCodecsConfiguration.kt index ebeafd694bc..451001d0fd8 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/httpcodecs/MyCodecsConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/reactive/webflux/httpcodecs/MyCodecsConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,6 +22,7 @@ import org.springframework.http.codec.CodecConfigurer import org.springframework.http.codec.ServerSentEventHttpMessageReader class MyCodecsConfiguration { + @Bean fun myCodecCustomizer(): CodecCustomizer { return CodecCustomizer { configurer: CodecConfigurer -> @@ -29,4 +30,5 @@ class MyCodecsConfiguration { configurer.customCodecs().register(ServerSentEventHttpMessageReader()) } } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/security/oauth2/client/MyOAuthClientConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/security/oauth2/client/MyOAuthClientConfiguration.kt similarity index 89% rename from spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/security/oauth2/client/MyOAuthClientConfiguration.kt rename to spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/security/oauth2/client/MyOAuthClientConfiguration.kt index 5f4055f620c..1390d9dc80f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/security/oauth2/client/MyOAuthClientConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/security/oauth2/client/MyOAuthClientConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.features.security.oauth2.client +package org.springframework.boot.docs.web.security.oauth2.client import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration @@ -23,10 +23,12 @@ import org.springframework.security.web.SecurityFilterChain @Configuration(proxyBeanMethods = false) class MyOAuthClientConfiguration { + @Bean fun securityFilterChain(http: HttpSecurity): SecurityFilterChain { http.authorizeRequests().anyRequest().authenticated() http.oauth2Login().redirectionEndpoint().baseUri("custom-callback") return http.build() } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/security/springwebflux/MyWebFluxSecurityConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/security/springwebflux/MyWebFluxSecurityConfiguration.kt similarity index 75% rename from spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/security/springwebflux/MyWebFluxSecurityConfiguration.kt rename to spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/security/springwebflux/MyWebFluxSecurityConfiguration.kt index 0cf07ca983e..460b64fe7b6 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/features/security/springwebflux/MyWebFluxSecurityConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/security/springwebflux/MyWebFluxSecurityConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,27 +14,25 @@ * limitations under the License. */ -package org.springframework.boot.docs.features.security.springwebflux +package org.springframework.boot.docs.web.security.springwebflux import org.springframework.boot.autoconfigure.security.reactive.PathRequest import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.security.config.web.server.ServerHttpSecurity -import org.springframework.security.config.web.server.ServerHttpSecurity.AuthorizeExchangeSpec import org.springframework.security.web.server.SecurityWebFilterChain @Configuration(proxyBeanMethods = false) class MyWebFluxSecurityConfiguration { + @Bean fun springSecurityFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain { - http.authorizeExchange { spec: AuthorizeExchangeSpec -> - spec.matchers( - PathRequest.toStaticResources() - .atCommonLocations() - ).permitAll() + http.authorizeExchange { spec -> + spec.matchers(PathRequest.toStaticResources().atCommonLocations()).permitAll() spec.pathMatchers("/foo", "/bar").authenticated() } http.formLogin() return http.build() } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/embeddedcontainer/customizing/programmatic/MyTomcatWebServerFactoryCustomizer.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/embeddedcontainer/customizing/programmatic/MyTomcatWebServerFactoryCustomizer.kt index 4cface1e70f..afae94fc8f1 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/embeddedcontainer/customizing/programmatic/MyTomcatWebServerFactoryCustomizer.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/embeddedcontainer/customizing/programmatic/MyTomcatWebServerFactoryCustomizer.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,19 +16,16 @@ package org.springframework.boot.docs.web.servlet.embeddedcontainer.customizing.programmatic -import org.apache.catalina.connector.Connector -import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory import org.springframework.boot.web.server.WebServerFactoryCustomizer import org.springframework.stereotype.Component import java.time.Duration @Component -class MyTomcatWebServerFactoryCustomizer : - WebServerFactoryCustomizer { +class MyTomcatWebServerFactoryCustomizer : WebServerFactoryCustomizer { + override fun customize(server: TomcatServletWebServerFactory) { - server.addConnectorCustomizers(TomcatConnectorCustomizer { connector: Connector -> - connector.asyncTimeout = Duration.ofSeconds(20).toMillis() - }) + server.addConnectorCustomizers({ connector -> connector.asyncTimeout = Duration.ofSeconds(20).toMillis() }) } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/embeddedcontainer/customizing/programmatic/MyWebServerFactoryCustomizer.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/embeddedcontainer/customizing/programmatic/MyWebServerFactoryCustomizer.kt index 53c98e60a87..70194c128d8 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/embeddedcontainer/customizing/programmatic/MyWebServerFactoryCustomizer.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/embeddedcontainer/customizing/programmatic/MyWebServerFactoryCustomizer.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,9 +21,10 @@ import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerF import org.springframework.stereotype.Component @Component -class MyWebServerFactoryCustomizer : - WebServerFactoryCustomizer { +class MyWebServerFactoryCustomizer : WebServerFactoryCustomizer { + override fun customize(server: ConfigurableServletWebServerFactory) { server.setPort(9000) } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/embeddedcontainer/customizing/samesite/MySameSiteConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/embeddedcontainer/customizing/samesite/MySameSiteConfiguration.kt index 599b97436a3..9884766858c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/embeddedcontainer/customizing/samesite/MySameSiteConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/embeddedcontainer/customizing/samesite/MySameSiteConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,8 +22,10 @@ import org.springframework.context.annotation.Configuration @Configuration(proxyBeanMethods = false) class MySameSiteConfiguration { + @Bean fun applicationCookieSameSiteSupplier(): CookieSameSiteSupplier { return CookieSameSiteSupplier.ofLax().whenHasNameMatching("myapp.*") } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/jersey/MyEndpoint.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/jersey/MyEndpoint.kt index 25f83420374..2c045d722a7 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/jersey/MyEndpoint.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/jersey/MyEndpoint.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,8 +23,10 @@ import javax.ws.rs.Path @Component @Path("/hello") class MyEndpoint { + @GET fun message(): String { return "Hello" } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/jersey/MyJerseyConfig.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/jersey/MyJerseyConfig.kt index 87a8e96384b..fcf034daa25 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/jersey/MyJerseyConfig.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/jersey/MyJerseyConfig.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -21,7 +21,9 @@ import org.springframework.stereotype.Component @Component class MyJerseyConfig : ResourceConfig() { + init { register(MyEndpoint::class.java) } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/Customer.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/Customer.kt index 39e6fe575b3..4aa5778227c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/Customer.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/Customer.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,5 +16,4 @@ package org.springframework.boot.docs.web.servlet.springmvc -class Customer { -} \ No newline at end of file +class Customer diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/CustomerRepository.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/CustomerRepository.kt index 30946b68e71..5dbdc55cfad 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/CustomerRepository.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/CustomerRepository.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -18,7 +18,8 @@ package org.springframework.boot.docs.web.servlet.springmvc import org.springframework.data.repository.CrudRepository -interface CustomerRepository : - CrudRepository { +interface CustomerRepository : CrudRepository { + fun findByUser(user: User?): List? + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/MyRestController.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/MyRestController.kt index b14fe1930a7..3e44766f833 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/MyRestController.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/MyRestController.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,12 +16,17 @@ package org.springframework.boot.docs.web.servlet.springmvc -import org.springframework.web.bind.annotation.* +import org.springframework.web.bind.annotation.DeleteMapping +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/users") class MyRestController(private val userRepository: UserRepository, private val customerRepository: CustomerRepository) { + @GetMapping("/{user}") fun getUser(@PathVariable userId: Long): User { return userRepository.findById(userId).get() @@ -29,15 +34,13 @@ class MyRestController(private val userRepository: UserRepository, private val c @GetMapping("/{user}/customers") fun getUserCustomers(@PathVariable userId: Long): List { - return userRepository.findById(userId).map { user: User? -> - customerRepository.findByUser( - user - ) - }.get() + return userRepository.findById(userId).map(customerRepository::findByUser).get() } @DeleteMapping("/{user}") fun deleteUser(@PathVariable userId: Long) { userRepository.deleteById(userId) } + } + diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/User.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/User.kt index f2af3a9d588..2d3d3c6d88b 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/User.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/User.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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,6 +17,8 @@ package org.springframework.boot.docs.web.servlet.springmvc class User { + val customers: List? get() = null -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/UserRepository.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/UserRepository.kt index f4e0c00d0ac..b2eb0c7afb7 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/UserRepository.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/UserRepository.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -18,5 +18,4 @@ package org.springframework.boot.docs.web.servlet.springmvc import org.springframework.data.repository.CrudRepository -interface UserRepository : - CrudRepository \ No newline at end of file +interface UserRepository : CrudRepository diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/cors/MyCorsConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/cors/MyCorsConfiguration.kt index cc79e028fd2..c7230542a36 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/cors/MyCorsConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/cors/MyCorsConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,6 +23,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer @Configuration(proxyBeanMethods = false) class MyCorsConfiguration { + @Bean fun corsConfigurer(): WebMvcConfigurer { return object : WebMvcConfigurer { @@ -31,4 +32,5 @@ class MyCorsConfiguration { } } } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/CustomException.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/CustomException.kt index 3103714942a..e53132940e2 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/CustomException.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/CustomException.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,4 +16,4 @@ package org.springframework.boot.docs.web.servlet.springmvc.errorhandling -class CustomException : RuntimeException() \ No newline at end of file +class CustomException : RuntimeException() diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/MyController.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/MyController.kt index ff77f177a09..83052c77490 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/MyController.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/MyController.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,9 +23,11 @@ import javax.servlet.http.HttpServletRequest @Controller class MyController { + @ExceptionHandler(CustomException::class) fun handleCustomException(request: HttpServletRequest, ex: CustomException?): String { request.setAttribute(ErrorAttributes.ERROR_ATTRIBUTE, ex) return "errorView" } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/MyControllerAdvice.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/MyControllerAdvice.kt index aa90371ec63..6f32ae136a2 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/MyControllerAdvice.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/MyControllerAdvice.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -27,10 +27,9 @@ import javax.servlet.http.HttpServletRequest @ControllerAdvice(basePackageClasses = [SomeController::class]) class MyControllerAdvice : ResponseEntityExceptionHandler() { + @ResponseBody - @ExceptionHandler( - MyException::class - ) + @ExceptionHandler(MyException::class) fun handleControllerException(request: HttpServletRequest, ex: Throwable): ResponseEntity<*> { val status = getStatus(request) return ResponseEntity(MyErrorBody(status.value(), ex.message), status) @@ -41,4 +40,5 @@ class MyControllerAdvice : ResponseEntityExceptionHandler() { val status = HttpStatus.resolve(code) return status ?: HttpStatus.INTERNAL_SERVER_ERROR } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/errorpages/MyErrorViewResolver.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/errorpages/MyErrorViewResolver.kt index 0ac8f593f07..f3d6ccb7846 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/errorpages/MyErrorViewResolver.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/errorpages/MyErrorViewResolver.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,16 +22,15 @@ import org.springframework.web.servlet.ModelAndView import javax.servlet.http.HttpServletRequest class MyErrorViewResolver : ErrorViewResolver { - override fun resolveErrorView( - request: HttpServletRequest, - status: HttpStatus, - model: Map - ): ModelAndView? { + + override fun resolveErrorView(request: HttpServletRequest, status: HttpStatus, + model: Map): ModelAndView? { // Use the request or status to optionally return a ModelAndView if (status == HttpStatus.INSUFFICIENT_STORAGE) { // We could add custom model values here - ModelAndView("myview") + return ModelAndView("myview") } return null } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/errorpageswithoutspringmvc/MyErrorPagesConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/errorpageswithoutspringmvc/MyErrorPagesConfiguration.kt index 837d101b1dd..f901d0248a7 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/errorpageswithoutspringmvc/MyErrorPagesConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/errorpageswithoutspringmvc/MyErrorPagesConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -25,6 +25,7 @@ import org.springframework.http.HttpStatus @Configuration(proxyBeanMethods = false) class MyErrorPagesConfiguration { + @Bean fun errorPageRegistrar(): ErrorPageRegistrar { return ErrorPageRegistrar { registry: ErrorPageRegistry -> registerErrorPages(registry) } @@ -33,4 +34,5 @@ class MyErrorPagesConfiguration { private fun registerErrorPages(registry: ErrorPageRegistry) { registry.addErrorPages(ErrorPage(HttpStatus.BAD_REQUEST, "/400")) } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/errorpageswithoutspringmvc/MyFilter.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/errorpageswithoutspringmvc/MyFilter.kt index 1281dd58150..326aa1c1f77 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/errorpageswithoutspringmvc/MyFilter.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/errorpageswithoutspringmvc/MyFilter.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -22,6 +22,8 @@ import javax.servlet.ServletRequest import javax.servlet.ServletResponse class MyFilter : GenericFilterBean() { + override fun doFilter(request: ServletRequest, response: ServletResponse, chain: FilterChain) { } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/errorpageswithoutspringmvc/MyFilterConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/errorpageswithoutspringmvc/MyFilterConfiguration.kt index e9d6587cb26..80cd176a5e3 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/errorpageswithoutspringmvc/MyFilterConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/errorhandling/errorpageswithoutspringmvc/MyFilterConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -19,11 +19,12 @@ package org.springframework.boot.docs.web.servlet.springmvc.errorhandling.errorp import org.springframework.boot.web.servlet.FilterRegistrationBean import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration -import java.util.* +import java.util.EnumSet import javax.servlet.DispatcherType @Configuration(proxyBeanMethods = false) class MyFilterConfiguration { + @Bean fun myFilter(): FilterRegistrationBean { val registration = FilterRegistrationBean(MyFilter()) @@ -31,4 +32,5 @@ class MyFilterConfiguration { registration.setDispatcherTypes(EnumSet.allOf(DispatcherType::class.java)) return registration } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/json/MyJsonComponent.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/json/MyJsonComponent.kt index 12be9dde6b5..3d51876ceab 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/json/MyJsonComponent.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/json/MyJsonComponent.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -19,13 +19,18 @@ package org.springframework.boot.docs.web.servlet.springmvc.json import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.JsonParser import com.fasterxml.jackson.core.JsonProcessingException -import com.fasterxml.jackson.databind.* +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.JsonDeserializer +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.JsonSerializer +import com.fasterxml.jackson.databind.SerializerProvider import org.springframework.boot.jackson.JsonComponent import java.io.IOException import kotlin.jvm.Throws @JsonComponent class MyJsonComponent { + class Serializer : JsonSerializer() { @Throws(IOException::class) override fun serialize(value: MyObject, jgen: JsonGenerator, serializers: SerializerProvider) { @@ -44,4 +49,5 @@ class MyJsonComponent { return MyObject(name, age) } } + } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/json/MyObject.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/json/MyObject.kt index 9144150d8d3..66df4a49b3d 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/json/MyObject.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/json/MyObject.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,4 +16,4 @@ package org.springframework.boot.docs.web.servlet.springmvc.json -class MyObject(val name: String = "", val age: Int = 0) \ No newline at end of file +class MyObject(val name: String = "", val age: Int = 0) diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/json/object/MyJsonComponent.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/json/object/MyJsonComponent.kt index d830ad62659..5a4268d67db 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/json/object/MyJsonComponent.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/json/object/MyJsonComponent.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -30,6 +30,7 @@ import kotlin.jvm.Throws @JsonComponent class MyJsonComponent { + class Serializer : JsonObjectSerializer() { @Throws(IOException::class) override fun serializeObject(value: MyObject, jgen: JsonGenerator, provider: SerializerProvider) { @@ -40,13 +41,12 @@ class MyJsonComponent { class Deserializer : JsonObjectDeserializer() { @Throws(IOException::class) - override fun deserializeObject( - jsonParser: JsonParser, context: DeserializationContext, codec: ObjectCodec, - tree: JsonNode - ): MyObject { + override fun deserializeObject(jsonParser: JsonParser, context: DeserializationContext, + codec: ObjectCodec, tree: JsonNode): MyObject { val name = nullSafeValue(tree["name"], String::class.java) val age = nullSafeValue(tree["age"], Int::class.java) return MyObject(name, age) } } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/json/object/MyObject.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/json/object/MyObject.kt index 3d02c074a60..08e5296a0ce 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/json/object/MyObject.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/json/object/MyObject.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -16,4 +16,4 @@ package org.springframework.boot.docs.web.servlet.springmvc.json.`object` -class MyObject(val name: String = "", val age: Int = 0) \ No newline at end of file +class MyObject(val name: String = "", val age: Int = 0) diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/messageconverters/AdditionalHttpMessageConverter.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/messageconverters/AdditionalHttpMessageConverter.kt index b1cc6fb599c..15185badea1 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/messageconverters/AdditionalHttpMessageConverter.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/messageconverters/AdditionalHttpMessageConverter.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -24,8 +24,8 @@ import org.springframework.http.converter.HttpMessageNotWritableException import java.io.IOException import kotlin.jvm.Throws -open class AdditionalHttpMessageConverter : - AbstractHttpMessageConverter() { +open class AdditionalHttpMessageConverter : AbstractHttpMessageConverter() { + override fun supports(clazz: Class<*>?): Boolean { return false } @@ -38,4 +38,5 @@ open class AdditionalHttpMessageConverter : @Throws(IOException::class, HttpMessageNotWritableException::class) override fun writeInternal(t: Any?, outputMessage: HttpOutputMessage) { } -} \ No newline at end of file + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/messageconverters/AnotherHttpMessageConverter.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/messageconverters/AnotherHttpMessageConverter.kt index a3b78f156fe..72a0a4779f0 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/messageconverters/AnotherHttpMessageConverter.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/messageconverters/AnotherHttpMessageConverter.kt @@ -1,3 +1,19 @@ +/* + * Copyright 2012-2022 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.boot.docs.web.servlet.springmvc.messageconverters -class AnotherHttpMessageConverter : AdditionalHttpMessageConverter() \ No newline at end of file +class AnotherHttpMessageConverter : AdditionalHttpMessageConverter() diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/messageconverters/MyHttpMessageConvertersConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/messageconverters/MyHttpMessageConvertersConfiguration.kt index b90507da113..8a1c6606e65 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/messageconverters/MyHttpMessageConvertersConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/servlet/springmvc/messageconverters/MyHttpMessageConvertersConfiguration.kt @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -23,10 +23,12 @@ import org.springframework.http.converter.HttpMessageConverter @Configuration(proxyBeanMethods = false) class MyHttpMessageConvertersConfiguration { + @Bean fun customConverters(): HttpMessageConverters { val additional: HttpMessageConverter<*> = AdditionalHttpMessageConverter() val another: HttpMessageConverter<*> = AnotherHttpMessageConverter() return HttpMessageConverters(additional, another) } -} \ No newline at end of file + +}