【问题标题】:Camel-Bindy (2.21.2) Fixed length unmarshalling appears to be ignoring trim=true annotationCamel-Bindy (2.21.2) 固定长度解组似乎忽略了 trim=true 注释
【发布时间】:2019-02-13 11:58:28
【问题描述】:

我有一个使用 Bindy 2.17 的类,但在迁移到 Camel 2.21.2 后,当我解组时它不再修剪传入的数据。

我尝试在记录注释中添加paddingChar 属性,但这没有任何效果,因为我要修剪的是空格,所以无论如何它应该是默认的paddingChar 值。

我的课是这样的

@FixedLengthRecord( header = MyClass.MyHeader.class, footer = MyClass.MyFooter.class, skipHeader = true, skipFooter = true, ignoreTrailingChars = true, crlf="WINDOWS", paddingChar = ' ' )
public class MyClass{

    @DataField( pos = 1, length = 2, trim = true )
    private String field1;

    @DataField( pos = 2, length = 15, trim = true )
    private String field2;

    @DataField( pos = 3, length = 15, trim = true )
    private String field3;

    @FixedLengthRecord( ignoreTrailingChars = true )
    public static class MyHeader {

    }

    @FixedLengthRecord( ignoreTrailingChars = true)
    public static class MyFooter {

    }

}

trim 的配置方式是否发生了变化,或者我还缺少什么?

谢谢!

【问题讨论】:

  • 你能试试更新的版本吗,有2.23.1,或者2.21.5
  • 由于时间限制不容易 - 但我会尝试在不同的环境中安装更高版本并检查问题是否相同。

标签: apache-camel bindy


【解决方案1】:

我也遇到了同样的问题。默认情况下,固定长度的记录向右对齐。从版本 2.18 开始,在这种情况下,只修剪记录左侧的填充字符。如果您的填充字符始终在右侧,您可以使用 align="L" 将记录左对齐。如果您只想修剪与对齐无关的所有内容,则可以从 2.20 版本开始使用 align="B"。以下是相关更改:https://github.com/apache/camel/commit/26aa4e8f14cac9dcdaa8f369a8045b8e8df56f1e#diff-24aaa851bf960dc4d2e04c5fbbf8aada

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-08
    • 2011-12-22
    • 1970-01-01
    • 1970-01-01
    • 2014-01-12
    • 2021-10-28
    • 2016-09-30
    相关资源
    最近更新 更多