-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug
Milestone
Description
Imagine, you have a bean with an init method, annotated with @PostConstruct and a configuration class, referencing the same init method on its own.
public class MyBean {
@PostConstruct
public void init() {
...
}
}@Configuration
public class MyConfiguration {
@Bean(initMethod = "init")
public MyBean myBean() {
return new MyBean();
}
}The init method will be invoked only once (what is pretty well).
This is true for all method modifiers except private.
As soon as you change the method modifier to private the init method is invoked twice.
public class MyBean {
@PostConstruct
- public void init() {
+ private void init() {
...
}
}Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug