Skip to content

Commit 7441930

Browse files
committed
Disable CGLIB proxies by default with ProjectGenerationConfiguration
Closes gh-1429
1 parent 3dd1036 commit 7441930

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

initializr-generator/src/main/java/io/spring/initializr/generator/project/ProjectGenerationConfiguration.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,10 +25,12 @@
2525
import org.springframework.context.ApplicationContext;
2626
import org.springframework.context.annotation.Conditional;
2727
import org.springframework.context.annotation.Configuration;
28+
import org.springframework.core.annotation.AliasFor;
2829
import org.springframework.core.io.support.SpringFactoriesLoader;
2930

3031
/**
31-
* Specialization of {@link Configuration} for configuration of project generation.
32+
* Specialization of {@link Configuration} for configuration of project generation, with
33+
* {@link Configuration#proxyBeanMethods()} set to {@code false} by default.
3234
* <p>
3335
* Project generation configuration classes are regular Spring {@link Configuration}
3436
* beans. They are located using the {@link SpringFactoriesLoader} mechanism (keyed
@@ -49,4 +51,14 @@
4951
@Configuration
5052
public @interface ProjectGenerationConfiguration {
5153

54+
/**
55+
* Specify whether {@code @Bean} methods should get proxied in order to enforce bean
56+
* lifecycle behavior, e.g. to return shared singleton bean instances even in case of
57+
* direct {@code @Bean} method calls in user code.
58+
* @see Configuration#proxyBeanMethods()
59+
* @return whether a CGLIB proxy should be created to enforce bean lifecycle behavior
60+
*/
61+
@AliasFor(annotation = Configuration.class)
62+
boolean proxyBeanMethods() default false;
63+
5264
}

0 commit comments

Comments
 (0)