如何在Spring集成中使用JAVA配置创建xslt-transformer?
作者:互联网
我在Spring-Integration中有以下xslt-transformer.如何使用Java Config进行相同的配置?
<si-xml:xslt-transformer input-channel="input" output-channel="output"
xsl-resource="classpath:/test.xsl"
result-transformer="resultToDoc"/>
解决方法:
@Transformer(inputChannel = "input", outputChannel = "output")
@Bean
public XsltPayloadTransformer transformer() {
return new XsltPayloadTransformer(new ClassPathResource("classpath:/test.xsl"),
resultToDoc());
}
从另一面考虑使用Spring Integration Java DSL,在这里我会更简单:
@Value("classpath:/test.xsl")
private Resource xsl;
.transform(Transformers.xslt(this.xsl))
标签:xml,xslt,spring,java,spring-integration 来源: https://codeday.me/bug/20191118/2031922.html