使用WebParam不允许使用XmlElement注释 [英] XmlElement annotation dissallowed with WebParam

查看:436
本文介绍了使用WebParam不允许使用XmlElement注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在webservice中有一个方法,具有以下签名:

I have a method inside a webservice, with the following signature:

@WebResult(name="purchaseId") public int CreatePurchase(
            @XmlElement(required=true)
            @WebParam(name = "item") String item {
  ...
}

在我看来(根据我发现的信息),这个应该工作。不幸的是,我在编译时收到以下错误消息:

It seems to me (based on what information i've found) that this should work. Unfortunately, I get the following error message on compilation:

The annotation @XmlElement is disallowed for this location

有谁知道如何解决这个问题?

Does anyone know how to resolve the issue?

推荐答案

JAX-B默认包含在JDK中。特定JDK附带的版本几乎没有像JAX-B本身那样频繁更新.JDK(1.6)附带的当前版本是JAX- B 2.1.10(记录此处)。

JAX-B is included with a JDK by default. The version that comes with the particular JDK isn't updated nearly as frequently as JAX-B itself. The current version that comes with the JDK (1.6) is JAX-B 2.1.10 (documented here).

@XmlElement仅允许在以JAX-B开头的方法参数2.2

@XmlElement is only allowed on method parameters starting with JAX-B 2.2

Java加载库,它加载JDK附带的库,然后加载类路径上的库。上传到Java 7将解决您的问题。如果您无法升级到Java 7,还有一个告诉Java您想要使用更新库的过程。这些被称为认可库,您必须将库放在同一个库中文件夹结构为JDK本身。该过程在此处中进行了描述。

When Java loads libaries it loads libraries that come with the JDK before it loads libraries that are on the classpath. Upgrdading to Java 7 would fix your problem. There is also a process for telling Java that you want to use a more up-to-date library if you aren't able to upgrade to Java 7. These are called "endorsed" libraries and you have to put the library in the same folder structure as the JDK itself. The process is described here.

这篇关于使用WebParam不允许使用XmlElement注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆