【发布时间】:2020-02-10 03:05:32
【问题描述】:
在配置类中我定义了几个@Beans。问题是某些 bean 在调用时会在其他类中重新调整 null。我想了解为什么会这样。
SoapConfig.class
@Configuration
@ComponentScan(basePackages = {"mk.test.wsdl","mk.test.Porting"})
public Jaxb2Marshaller marshaller(){
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath("mk.softnet.wsdl");
System.out.println("out:" + marshaller);
return marshaller;
}
@Bean
public SaajSoapMessageFactory messageFactory() {
SaajSoapMessageFactory messageFactory = new SaajSoapMessageFactory();
messageFactory.setSoapVersion(SoapVersion.SOAP_12);
return messageFactory;
}
@Bean
public KeyStoreFactoryBean keyStoreFactoryBean(){
KeyStoreFactoryBean keyStoreFactoryBean = new KeyStoreFactoryBean();
keyStoreFactoryBean.setPassword("test");
keyStoreFactoryBean.setLocation(new
ClassPathResource("test.jks"));
return keyStoreFactoryBean;
}
SoapClinet.class
private Jaxb2Marshaller marshaller;
在方法中:
System.out.println(marshaller) //我得到一些值,例如:marshalar: org.springframework.oxm.jaxb.Jaxb2Marshaller@376c7d7d(我不知道这是什么意思)
但是如果我 System.out..."keyStoreFactoryBean" 或 "messageFactory" 我总是得到 null,我需要在 SoapClient.class 中定义它
只有表明某事的信息是这样的: [org.springframework.ws.soap.security.support.KeyStoreFactoryBean] 类型的 Bean 'keyStoreFactoryBean' 不符合被所有 BeanPostProcessor 处理的条件(例如:不符合自动代理条件)
但从我的阅读来看,这不是错误。
【问题讨论】:
标签: spring spring-boot