【问题标题】:Cant get Castor's MappingTool to work无法让 Castor Mapping Tool 工作
【发布时间】:2012-09-13 21:48:16
【问题描述】:

我正在尝试使用该程序使用 Castor 1.3.2 自动生成映射文件。

但这是我得到的例外 - java.lang.IllegalArgumentException:没有枚举常量类 org.exolab.castor.mapping.xml.types.BindXmlNodeType.element

这是一个相当基本的测试,我做错了什么?

公共类 CastorMapping {

    public CastorMapping()
    {
        try
        {
            MappingTool tool = new MappingTool();
            tool.setInternalContext(new org.castor.xml.BackwardCompatibilityContext());
            tool.addClass(TestRequest.class);
            OutputStream file = new FileOutputStream("gen_mapping.xml" );
            Writer writer = new OutputStreamWriter(file);
            tool.write(writer);
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
    }

    public static void main(String[] args)
    {
        new CastorMapping();
    }

}

谢谢!

【问题讨论】:

    标签: java web-services web castor


    【解决方案1】:

    我自己试过了,我相信你做的一切都是正确的。

    我浏览了 castor 源代码,据我所知,当他们将 BindXmlNodeType 重新设计为枚举类而不是常规类时,他们在 1.3 和 1.3.2 之间的某个地方破坏了 MappingTool。有一些代码他们正在寻找 BindXmlNodeType.element,但现在 BindXmlNodeType 是一个枚举,他们需要查找 ELEMENT(大写字母)。但我离题了...

    如果您有能力恢复到 Castor 1.3,那么一切都会正常。

    顺便说一句 - 我尝试升级到 1.3.3-rc1,但 Intellij 无法解决 maven 依赖项。例如 1.3.3-rc1 中的 castor-xml 现在依赖于 Spring!这个错误可能会在以后的版本中修复,但我不抱希望。

    【讨论】:

    • 非常感谢,这很有帮助,我会试试看!
    • @Guido Simone,Castor-0.9.5.4 版本是否支持此功能?我在那里找不到BackwardCompatibilityContext 类。
    • 谢谢,您的回答解释了我们的大问题!
    猜你喜欢
    • 2013-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-23
    • 2014-12-26
    • 2017-12-22
    • 2012-02-28
    相关资源
    最近更新 更多