In my test environment, only the client is used(setForceServerMode(true)). Operating environments use clients and servers.
Sometimes Injection is not required in the test environment.
NoSuchBeanDefinitionException is not generated by specifying a value of false.
public @interface SpringResource {
/**
- Declares whether the annotated dependency is required.
- <p>Defaults to
{@code true}
.
*/
boolean required() default true;
..
if (!StringUtils.isEmpty(beanName)) {
try
catch(NoSuchBeanDefinitionException ne) {
if(annotation.required())
}
}
else {
try { bean = springCtx.getBean(beanCls); } catch(NoSuchBeanDefinitionException ne) {
if(annotation.required()) { throw ne; }
}
}
- links to