Skip to content

Commit 460ffbc

Browse files
committedMar 12, 2024·
Use code includes and tabs in mvc-controller/ann.adoc
See spring-projectsgh-22171
1 parent 8a67018 commit 460ffbc

File tree

5 files changed

+78
-50
lines changed

5 files changed

+78
-50
lines changed
 

‎framework-docs/modules/ROOT/pages/web/webflux/controller/ann.adoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Java::
2020
----
2121
@Configuration
2222
@ComponentScan("org.example.web") // <1>
23-
public class WebConfig {
23+
public class WebConfiguration {
2424
2525
// ...
2626
}
@@ -33,7 +33,7 @@ Kotlin::
3333
----
3434
@Configuration
3535
@ComponentScan("org.example.web") // <1>
36-
class WebConfig {
36+
class WebConfiguration {
3737
3838
// ...
3939
}

‎framework-docs/modules/ROOT/pages/web/webmvc/mvc-controller/ann.adoc

+1-48
Original file line numberDiff line numberDiff line change
@@ -12,54 +12,7 @@ annotated class, indicating its role as a web component.
1212
To enable auto-detection of such `@Controller` beans, you can add component scanning to
1313
your Java configuration, as the following example shows:
1414

15-
[tabs]
16-
======
17-
Java::
18-
+
19-
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
20-
----
21-
@Configuration
22-
@ComponentScan("org.example.web")
23-
public class WebConfig {
24-
25-
// ...
26-
}
27-
----
28-
29-
Kotlin::
30-
+
31-
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
32-
----
33-
@Configuration
34-
@ComponentScan("org.example.web")
35-
class WebConfig {
36-
37-
// ...
38-
}
39-
----
40-
======
41-
42-
The following example shows the XML configuration equivalent of the preceding example:
43-
44-
[source,xml,indent=0,subs="verbatim,quotes"]
45-
----
46-
<?xml version="1.0" encoding="UTF-8"?>
47-
<beans xmlns="http://www.springframework.org/schema/beans"
48-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
49-
xmlns:p="http://www.springframework.org/schema/p"
50-
xmlns:context="http://www.springframework.org/schema/context"
51-
xsi:schemaLocation="
52-
http://www.springframework.org/schema/beans
53-
https://www.springframework.org/schema/beans/spring-beans.xsd
54-
http://www.springframework.org/schema/context
55-
https://www.springframework.org/schema/context/spring-context.xsd">
56-
57-
<context:component-scan base-package="org.example.web"/>
58-
59-
<!-- ... -->
60-
61-
</beans>
62-
----
15+
include-code::./WebConfiguration[tag=snippet,indent=0]
6316

6417
`@RestController` is a xref:core/beans/classpath-scanning.adoc#beans-meta-annotations[composed annotation] that is
6518
itself meta-annotated with `@Controller` and `@ResponseBody` to indicate a controller whose
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2002-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.docs.web.webmvc.mvccontroller.mvcanncontroller;
18+
19+
import org.springframework.context.annotation.ComponentScan;
20+
import org.springframework.context.annotation.Configuration;
21+
22+
// tag::snippet[]
23+
@Configuration
24+
@ComponentScan("org.example.web")
25+
public class WebConfiguration {
26+
27+
// ...
28+
}
29+
// end::snippet[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2002-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.docs.web.webmvc.mvccontroller.mvcanncontroller
18+
19+
import org.springframework.context.annotation.ComponentScan
20+
import org.springframework.context.annotation.Configuration
21+
22+
// tag::snippet[]
23+
@Configuration
24+
@ComponentScan("org.example.web")
25+
class WebConfiguration {
26+
27+
// ...
28+
}
29+
// end::snippet[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- tag::snippet[] -->
3+
<beans xmlns="http://www.springframework.org/schema/beans"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:context="http://www.springframework.org/schema/context"
6+
xsi:schemaLocation="
7+
http://www.springframework.org/schema/beans
8+
https://www.springframework.org/schema/beans/spring-beans.xsd
9+
http://www.springframework.org/schema/context
10+
https://www.springframework.org/schema/context/spring-context.xsd">
11+
12+
<context:component-scan base-package="org.example.web"/>
13+
14+
<!-- ... -->
15+
16+
</beans>
17+
<!-- end::snippet[] -->

0 commit comments

Comments
 (0)
Please sign in to comment.