primary
When multiple bean candidates appear during autowiring, they will be the first choice.
Corresponds to the primary of the bean tag attribute in the XML configuration. <bean id="xxx" class="xxx" primary="true">
Corresponding notes:@org.springframework.context.annotation.Primary
initMethodName
Initialization method.
Corresponds to the init-method of the bean tag attribute in the XML configuration. <bean id="xxx" class="xxx" init-method="xxx">
Corresponding notes:@javax.annotation.PostConstruct
destoryMethodName
Destruction method.
Corresponds to the destruction-method of the bean tag attribute in the XML configuration. <bean id="xxx" class="xxx" destroy-method="xxx">
Corresponding notes:@javax.annotation.PreDestroy
Annotation configuration case:
@Service
@org.springframework.context.annotation.Primary
public class GuavaCache implements ICache {
@Override
public void greet() {
// ...
}
@javax.annotation.PostConstruct
public void init() {
// ...
}
@javax.annotation.PreDestroy
public void destroy() {
// ...
}
}