eclipse - 我怎样才能治愈... cvc-elt.1 : Cannot find the declaration of element 'jaxb:bindings'

标签 eclipse binding jaxb xsd

有了这个 .xjb 文件,Eclipse 会提示它找不到元素 jaxb:bindings。这是从哪里来的?

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings xmlns="http://java.sun.com/xml/ns/jaxb"
    xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
    xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd" version="2.1">
    <jaxb:globalBindings>
        <jaxb:serializable uid="1" />
        <xjc:javaType name="java.lang.Integer" xmlType="xs:int" 
            adapter="com.foo.bar.jaxb.adapter.IntegerAdapter" />
        <xjc:javaType name="java.lang.Integer" xmlType="xs:integer" 
            adapter="com.foo.bar.jaxb.adapter.IntegerAdapter" />
        <xjc:javaType name="java.util.Date" xmlType="xs:time"
            adapter="com.foo.bar.jaxb.adapter.TimeAdapter" />
        <xjc:javaType name="java.util.Date" xmlType="xs:date"
            adapter="com.foo.bar.jaxb.adapter.DateAdapter" />
        <xjc:javaType name="java.util.Date" xmlType="xs:dateTime"
            adapter="com.foo.bar.jaxb.adapter.DateTimeAdapter" />
    </jaxb:globalBindings>
</jaxb:bindings>

Eclipse 在第 9 行提示:

cvc-elt.1: Cannot find the declaration of element 'jaxb:bindings'.



为什么...我怎样才能解决问题?

最佳答案

我在我的项目中使用这个配置..(maven 和 maven-jaxb2-plugin)

<bindings version="2.0" xmlns="http://java.sun.com/xml/ns/jaxb"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
    xmlns:annox="http://annox.dev.java.net">

  <globalBindings>
        <xjc:serializable uid="12343" />
        <xjc:simple/>
  </globalBindings>

</bindings>
删除 schemalocation 声明。

关于eclipse - 我怎样才能治愈... cvc-elt.1 : Cannot find the declaration of element 'jaxb:bindings' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25361908/

相关文章:

wpf - 在 WPF 中保持两个文本框同步

java - 将 Base64 字符串从 xml 文件复制到文本文件时出现问题

java - 在eclipse中构建错误

php - 如何使用eclipse查看php函数源代码

eclipse - Tomcat 转到 jsp、servlet 等 jar 的 .m2 目录并崩溃

wpf - 如何将 View 绑定(bind)到使用参数实例化的 View 模型?

c# - 如何将 WPF CheckBox 绑定(bind)到条件?

java - 用于 xml 解码的 JAXB 或 Jackson?

java - MOXy JAXB 在 XmlIDREF 上中断为具有枚举属性的类型

java - ListView 不显示 -- ListView 项目选择到 webView