gpt4 book ai didi

java - 如何在BeanIO中引用外部xml文件?

转载 作者:行者123 更新时间:2023-12-01 09:54:30 27 4
gpt4 key购买 nike

我一直在阅读 BeanIO 的模板部分,但我没有找到任何特定于带有模板的外部文件的内容。基本上,我试图创建一个 xml 文件来保存所有模板并引用其他文件中的特定模板。

我有这个文件 mytemplates.xml

<beanio>

<template name="theTemplate">
//template fields
</template>
</beanio>

我还有另一个名为 myfile.xml 的文件,它将使用 mytemplates.xml 中的模板

<beanio>
<stream name="aaa" format="fixedlength">
<include template="theTemplate"/>
</stream>
</beanio>

有办法做到这一点吗?

最佳答案

为了将来的引用,我在存储库中找到了答案,并且有人在 beanIO 组中也提到了它。希望能帮助到你。

<beanio xmlns="http://www.beanio.org/2012/03" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.beanio.org/2012/03 http://www.beanio.org/2012/03/mapping.xsd">



<--I had to go up to package level to make it work ie: org/app/myapp/mytemplates.xml-->
<import resource="classpath:mytemplates.xml"/>

<!-- the rest of your file -->
</beanio>

关于java - 如何在BeanIO中引用外部xml文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37353067/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com