Add init-method example
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package org.baeldung.startup;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Component
|
||||
@Scope(value = "prototype")
|
||||
public class InitMethodExampleBean {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(InitMethodExampleBean.class);
|
||||
|
||||
@Autowired
|
||||
private Environment environment;
|
||||
|
||||
public void init() {
|
||||
LOG.info(Arrays.asList(environment.getDefaultProfiles()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user