@@ -309,23 +309,23 @@ Typically, such configuration will live in a ".groovy" file with a structure as
309
309
[source,java,indent=0]
310
310
[subs="verbatim,quotes"]
311
311
----
312
- beans {
313
- dataSource(BasicDataSource) {
314
- driverClassName = "org.hsqldb.jdbcDriver"
315
- url = "jdbc:hsqldb:mem:grailsDB"
316
- username = "sa"
317
- password = ""
318
- settings = [mynew:"setting"]
319
- }
320
- sessionFactory(SessionFactory) {
321
- dataSource = dataSource
322
- }
323
- myService(MyService) {
324
- nestedBean = { AnotherBean bean ->
325
- dataSource = dataSource
326
- }
327
- }
328
- }
312
+ beans {
313
+ dataSource(BasicDataSource) {
314
+ driverClassName = "org.hsqldb.jdbcDriver"
315
+ url = "jdbc:hsqldb:mem:grailsDB"
316
+ username = "sa"
317
+ password = ""
318
+ settings = [mynew:"setting"]
319
+ }
320
+ sessionFactory(SessionFactory) {
321
+ dataSource = dataSource
322
+ }
323
+ myService(MyService) {
324
+ nestedBean = { AnotherBean bean ->
325
+ dataSource = dataSource
326
+ }
327
+ }
328
+ }
329
329
----
330
330
331
331
This configuration style is largely equivalent to XML bean definitions and even
@@ -373,7 +373,7 @@ delegates, e.g. with `XmlBeanDefinitionReader` for XML files:
373
373
----
374
374
GenericApplicationContext context = new GenericApplicationContext();
375
375
new XmlBeanDefinitionReader(context).loadBeanDefinitions("services.xml", "daos.xml");
376
- context.refresh();
376
+ context.refresh();
377
377
----
378
378
379
379
Or with `GroovyBeanDefinitionReader` for Groovy files:
@@ -383,7 +383,7 @@ Or with `GroovyBeanDefinitionReader` for Groovy files:
383
383
----
384
384
GenericApplicationContext context = new GenericApplicationContext();
385
385
new GroovyBeanDefinitionReader(context).loadBeanDefinitions("services.groovy", "daos.groovy");
386
- context.refresh();
386
+ context.refresh();
387
387
----
388
388
389
389
Such reader delegates can be mixed and matched on the same `ApplicationContext`,
@@ -1685,7 +1685,7 @@ The preceding example is equivalent to the following Java code:
1685
1685
[source,java,indent=0]
1686
1686
[subs="verbatim,quotes"]
1687
1687
----
1688
- exampleBean.setEmail("")
1688
+ exampleBean.setEmail("")
1689
1689
----
1690
1690
1691
1691
The `<null/>` element handles `null` values. For example:
@@ -3822,7 +3822,6 @@ Find below the custom `BeanPostProcessor` implementation class definition:
3822
3822
package scripting;
3823
3823
3824
3824
import org.springframework.beans.factory.config.BeanPostProcessor;
3825
- import org.springframework.beans.BeansException;
3826
3825
3827
3826
public class InstantiationTracingBeanPostProcessor implements BeanPostProcessor {
3828
3827
@@ -5400,7 +5399,7 @@ comma/semicolon/space-separated list that includes the parent package of each cl
5400
5399
@Configuration
5401
5400
@ComponentScan(basePackages = "org.example")
5402
5401
public class AppConfig {
5403
- ...
5402
+ ...
5404
5403
}
5405
5404
----
5406
5405
@@ -5511,12 +5510,12 @@ and using "stub" repositories instead.
5511
5510
[subs="verbatim,quotes"]
5512
5511
----
5513
5512
@Configuration
5514
- @ComponentScan(basePackages = "org.example",
5515
- includeFilters = @Filter(type = FilterType.REGEX, pattern = ".*Stub.*Repository"),
5516
- excludeFilters = @Filter(Repository.class))
5517
- public class AppConfig {
5518
- ...
5519
- }
5513
+ @ComponentScan(basePackages = "org.example",
5514
+ includeFilters = @Filter(type = FilterType.REGEX, pattern = ".*Stub.*Repository"),
5515
+ excludeFilters = @Filter(Repository.class))
5516
+ public class AppConfig {
5517
+ ...
5518
+ }
5520
5519
----
5521
5520
5522
5521
and the equivalent using XML
@@ -5746,10 +5745,10 @@ fully-qualified class name when configuring the scanner:
5746
5745
[subs="verbatim,quotes"]
5747
5746
----
5748
5747
@Configuration
5749
- @ComponentScan(basePackages = "org.example", nameGenerator = MyNameGenerator.class)
5750
- public class AppConfig {
5751
- ...
5752
- }
5748
+ @ComponentScan(basePackages = "org.example", nameGenerator = MyNameGenerator.class)
5749
+ public class AppConfig {
5750
+ ...
5751
+ }
5753
5752
----
5754
5753
5755
5754
[source,xml,indent=0]
@@ -5803,8 +5802,8 @@ fully-qualified class name when configuring the scanner:
5803
5802
@Configuration
5804
5803
@ComponentScan(basePackages = "org.example", scopeResolver = MyScopeResolver.class)
5805
5804
public class AppConfig {
5806
- ...
5807
- }
5805
+ ...
5806
+ }
5808
5807
----
5809
5808
5810
5809
[source,xml,indent=0]
@@ -5828,8 +5827,8 @@ the following configuration will result in standard JDK dynamic proxies:
5828
5827
@Configuration
5829
5828
@ComponentScan(basePackages = "org.example", scopedProxy = ScopedProxyMode.INTERFACES)
5830
5829
public class AppConfig {
5831
- ...
5832
- }
5830
+ ...
5831
+ }
5833
5832
----
5834
5833
5835
5834
[source,xml,indent=0]
@@ -6144,7 +6143,7 @@ exact same way as when using Spring annotations:
6144
6143
@Configuration
6145
6144
@ComponentScan(basePackages = "org.example")
6146
6145
public class AppConfig {
6147
- ...
6146
+ ...
6148
6147
}
6149
6148
----
6150
6149
@@ -6374,7 +6373,7 @@ To enable component scanning, just annotate your `@Configuration` class as follo
6374
6373
@Configuration
6375
6374
@ComponentScan(basePackages = "com.acme")
6376
6375
public class AppConfig {
6377
- ...
6376
+ ...
6378
6377
}
6379
6378
----
6380
6379
@@ -6693,7 +6692,7 @@ method directly during construction:
6693
6692
public Foo foo() {
6694
6693
Foo foo = new Foo();
6695
6694
foo.init();
6696
- return foo;
6695
+ return foo;
6697
6696
}
6698
6697
6699
6698
// ...
@@ -7011,7 +7010,7 @@ another configuration class:
7011
7010
@Configuration
7012
7011
public class ConfigA {
7013
7012
7014
- @Bean
7013
+ @Bean
7015
7014
public A a() {
7016
7015
return new A();
7017
7016
}
@@ -8681,18 +8680,18 @@ environment provides:
8681
8680
[subs="verbatim,quotes"]
8682
8681
----
8683
8682
public class EntityCreatedEvent<T>
8684
- extends ApplicationEvent implements ResolvableTypeProvider {
8685
-
8686
- public EntityCreatedEvent(T entity) {
8687
- super(entity);
8688
- }
8689
-
8690
- @Override
8691
- public ResolvableType getResolvableType() {
8692
- return ResolvableType.forClassWithGenerics(getClass(),
8693
- ResolvableType.forInstance(getSource()));
8694
- }
8695
- }
8683
+ extends ApplicationEvent implements ResolvableTypeProvider {
8684
+
8685
+ public EntityCreatedEvent(T entity) {
8686
+ super(entity);
8687
+ }
8688
+
8689
+ @Override
8690
+ public ResolvableType getResolvableType() {
8691
+ return ResolvableType.forClassWithGenerics(getClass(),
8692
+ ResolvableType.forInstance(getSource()));
8693
+ }
8694
+ }
8696
8695
----
8697
8696
8698
8697
[TIP]
0 commit comments