Java JAXB可以';在通过eclipse生成XSD时处理接口异常
我正在尝试通过eclipse生成XSD/schema 我得到下面提到的错误 Address.class:Java JAXB可以';在通过eclipse生成XSD时处理接口异常,java,eclipse,jaxb,jax-rs,jaxb2,Java,Eclipse,Jaxb,Jax Rs,Jaxb2,我正在尝试通过eclipse生成XSD/schema 我得到下面提到的错误 Address.class: package blog.interfaces; public interface Address { public String getStreet(); public void setStreet(String street); } package blog.interfaces;
package blog.interfaces;
public interface Address {
public String getStreet();
public void setStreet(String street);
}
package blog.interfaces;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="customer")
public class CustomerImpl implements Customer {
private Address address;
private List<PhoneNumber> phoneNumbers;
@XmlElement(type=AddressImpl.class)
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
@XmlElement(type=PhoneNumberImpl.class, name="phone-number")
public List<PhoneNumber> getPhoneNumbers() {
return phoneNumbers;
}
public void setPhoneNumbers(List<PhoneNumber> phoneNumbers) {
this.phoneNumbers = phoneNumbers;
}
}
!loading...!
!blog.interfaces.PhoneNumberImpl!
!blog.interfaces.Customer!
!blog.interfaces.AddressImpl!
!blog.interfaces.Address!
!blog.interfaces.CustomerImpl!
!blog.interfaces.PhoneNumber!
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 3 counts of IllegalAnnotationExceptions
blog.interfaces.Customer is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at blog.interfaces.Customer
blog.interfaces.Address is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at blog.interfaces.Address
at public abstract blog.interfaces.Address blog.interfaces.Customer.getAddress()
at blog.interfaces.Customer
blog.interfaces.PhoneNumber is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at blog.interfaces.PhoneNumber
at public abstract java.util.List blog.interfaces.Customer.getPhoneNumbers()
at blog.interfaces.Customer
at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:445)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:277)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:124)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1123)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:147)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:247)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:234)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:462)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
at org.eclipse.jpt.jaxb.core.schemagen.Main.buildJaxbContext(Main.java:99)
at org.eclipse.jpt.jaxb.core.schemagen.Main.generate(Main.java:78)
at org.eclipse.jpt.jaxb.core.schemagen.Main.execute(Main.java:64)
at org.eclipse.jpt.jaxb.core.schemagen.Main.main(Main.java:49)
!
Schema src\main\java\NewXMLSchema.xsd not created!
AddressImpl.class
package blog.interfaces;
public class AddressImpl implements Address {
private String street;
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
}
package blog.interfaces;
public interface PhoneNumber {
String getValue();
void setValue(String value);
}
package blog.interfaces;
import javax.xml.bind.annotation.XmlValue;
public class PhoneNumberImpl implements PhoneNumber {
private String value;
@XmlValue
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
package blog.interfaces;
import java.util.List;
public interface Customer {
Address getAddress();
void setAddress(Address address);
List<PhoneNumber> getPhoneNumbers();
void setPhoneNumbers(List<PhoneNumber> phoneNumbers);
}
PhoneNumber.class
package blog.interfaces;
public class AddressImpl implements Address {
private String street;
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
}
package blog.interfaces;
public interface PhoneNumber {
String getValue();
void setValue(String value);
}
package blog.interfaces;
import javax.xml.bind.annotation.XmlValue;
public class PhoneNumberImpl implements PhoneNumber {
private String value;
@XmlValue
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
package blog.interfaces;
import java.util.List;
public interface Customer {
Address getAddress();
void setAddress(Address address);
List<PhoneNumber> getPhoneNumbers();
void setPhoneNumbers(List<PhoneNumber> phoneNumbers);
}
PhoneNumberImpl.class
package blog.interfaces;
public class AddressImpl implements Address {
private String street;
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
}
package blog.interfaces;
public interface PhoneNumber {
String getValue();
void setValue(String value);
}
package blog.interfaces;
import javax.xml.bind.annotation.XmlValue;
public class PhoneNumberImpl implements PhoneNumber {
private String value;
@XmlValue
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
package blog.interfaces;
import java.util.List;
public interface Customer {
Address getAddress();
void setAddress(Address address);
List<PhoneNumber> getPhoneNumbers();
void setPhoneNumbers(List<PhoneNumber> phoneNumbers);
}
Customer.class
package blog.interfaces;
public class AddressImpl implements Address {
private String street;
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
}
package blog.interfaces;
public interface PhoneNumber {
String getValue();
void setValue(String value);
}
package blog.interfaces;
import javax.xml.bind.annotation.XmlValue;
public class PhoneNumberImpl implements PhoneNumber {
private String value;
@XmlValue
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
package blog.interfaces;
import java.util.List;
public interface Customer {
Address getAddress();
void setAddress(Address address);
List<PhoneNumber> getPhoneNumbers();
void setPhoneNumbers(List<PhoneNumber> phoneNumbers);
}
package blog.interfaces;
导入java.util.List;
公共接口客户{
地址getAddress();
无效设置地址(地址);
列出GetPhoneNumber();
作废设置电话号码(列出电话号码);
}
客户模板类:
package blog.interfaces;
public interface Address {
public String getStreet();
public void setStreet(String street);
}
package blog.interfaces;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="customer")
public class CustomerImpl implements Customer {
private Address address;
private List<PhoneNumber> phoneNumbers;
@XmlElement(type=AddressImpl.class)
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
@XmlElement(type=PhoneNumberImpl.class, name="phone-number")
public List<PhoneNumber> getPhoneNumbers() {
return phoneNumbers;
}
public void setPhoneNumbers(List<PhoneNumber> phoneNumbers) {
this.phoneNumbers = phoneNumbers;
}
}
!loading...!
!blog.interfaces.PhoneNumberImpl!
!blog.interfaces.Customer!
!blog.interfaces.AddressImpl!
!blog.interfaces.Address!
!blog.interfaces.CustomerImpl!
!blog.interfaces.PhoneNumber!
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 3 counts of IllegalAnnotationExceptions
blog.interfaces.Customer is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at blog.interfaces.Customer
blog.interfaces.Address is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at blog.interfaces.Address
at public abstract blog.interfaces.Address blog.interfaces.Customer.getAddress()
at blog.interfaces.Customer
blog.interfaces.PhoneNumber is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at blog.interfaces.PhoneNumber
at public abstract java.util.List blog.interfaces.Customer.getPhoneNumbers()
at blog.interfaces.Customer
at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:445)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:277)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:124)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1123)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:147)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:247)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:234)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:462)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
at org.eclipse.jpt.jaxb.core.schemagen.Main.buildJaxbContext(Main.java:99)
at org.eclipse.jpt.jaxb.core.schemagen.Main.generate(Main.java:78)
at org.eclipse.jpt.jaxb.core.schemagen.Main.execute(Main.java:64)
at org.eclipse.jpt.jaxb.core.schemagen.Main.main(Main.java:49)
!
Schema src\main\java\NewXMLSchema.xsd not created!
package blog.interfaces;
导入java.util.List;
导入javax.xml.bind.annotation.xmlement;
导入javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name=“客户”)
公共类CustomerImpl实现Customer{
私人地址;
私人电话号码列表;
@XmlElement(类型=AddressImpl.class)
公共广播getAddress(){
回信地址;
}
公共无效设置地址(地址){
this.address=地址;
}
@XmlElement(type=PhoneNumberImpl.class,name=“phone number”)
公共列表GetPhoneNumber(){
返回电话号码;
}
公用无效设置电话号码(列出电话号码){
this.phoneNumbers=电话号码;
}
}
来自eclipse JAXB的错误:
package blog.interfaces;
public interface Address {
public String getStreet();
public void setStreet(String street);
}
package blog.interfaces;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="customer")
public class CustomerImpl implements Customer {
private Address address;
private List<PhoneNumber> phoneNumbers;
@XmlElement(type=AddressImpl.class)
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
@XmlElement(type=PhoneNumberImpl.class, name="phone-number")
public List<PhoneNumber> getPhoneNumbers() {
return phoneNumbers;
}
public void setPhoneNumbers(List<PhoneNumber> phoneNumbers) {
this.phoneNumbers = phoneNumbers;
}
}
!loading...!
!blog.interfaces.PhoneNumberImpl!
!blog.interfaces.Customer!
!blog.interfaces.AddressImpl!
!blog.interfaces.Address!
!blog.interfaces.CustomerImpl!
!blog.interfaces.PhoneNumber!
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 3 counts of IllegalAnnotationExceptions
blog.interfaces.Customer is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at blog.interfaces.Customer
blog.interfaces.Address is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at blog.interfaces.Address
at public abstract blog.interfaces.Address blog.interfaces.Customer.getAddress()
at blog.interfaces.Customer
blog.interfaces.PhoneNumber is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at blog.interfaces.PhoneNumber
at public abstract java.util.List blog.interfaces.Customer.getPhoneNumbers()
at blog.interfaces.Customer
at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:445)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:277)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:124)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1123)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:147)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:247)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:234)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:462)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
at org.eclipse.jpt.jaxb.core.schemagen.Main.buildJaxbContext(Main.java:99)
at org.eclipse.jpt.jaxb.core.schemagen.Main.generate(Main.java:78)
at org.eclipse.jpt.jaxb.core.schemagen.Main.execute(Main.java:64)
at org.eclipse.jpt.jaxb.core.schemagen.Main.main(Main.java:49)
!
Schema src\main\java\NewXMLSchema.xsd not created!
!加载。。。!
!blog.interfaces.PhoneNumberImpl!
!blog.interfaces.Customer!
!blog.interfaces.AddressImpl!
!blog.interfaces.Address!
!blog.interfaces.CustomerImpl!
!blog.interfaces.PhoneNumber!
com.sun.xml.internal.bind.v2.runtime.illegalannotations异常:3次IllegalAnnotationExceptions计数
客户是一个接口,JAXB不能处理接口。
此问题与以下位置有关:
在blog.interfaces.Customer上
blog.interfaces.Address是一个接口,JAXB无法处理接口。
此问题与以下位置有关:
在blog.interfaces.Address
在public abstract blog.interfaces.Address blog.interfaces.Customer.getAddress()中
在blog.interfaces.Customer上
PhoneNumber是一个接口,JAXB无法处理接口。
此问题与以下位置有关:
在blog.interfaces.PhoneNumber
在公共抽象java.util.List blog.interfaces.Customer.getPhoneNumber()中
在blog.interfaces.Customer上
位于com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91)
位于com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:445)
位于com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:277)
位于com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:124)
位于com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1123)
位于com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:147)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)中
位于java.lang.reflect.Method.invoke(Method.java:498)
位于javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:247)
位于javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:234)
位于javax.xml.bind.ContextFinder.find(ContextFinder.java:462)
位于javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641)
位于javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
位于org.eclipse.jpt.jaxb.core.schemagen.Main.buildJaxbContext(Main.java:99)
位于org.eclipse.jpt.jaxb.core.schemagen.Main.generate(Main.java:78)
位于org.eclipse.jpt.jaxb.core.schemagen.Main.execute(Main.java:64)
位于org.eclipse.jpt.jaxb.core.schemagen.Main.Main(Main.java:49)
!
未创建模式src\main\java\NewXMLSchema.xsd!
请帮助有人可以回复吗?您是否阅读了此主题?:嗨,Andrey,谢谢您的回复。我正在尝试从eclipse生成xsd。这里有如何更改JAXBContext的引导(根据上面建议的链接)。我这里没有使用任何java程序进行封送。我使用eclipse插件生成XSD。我这里没有任何想法。有人可以回答吗?有人可以解释一下如何在XSD中重新呈现接口。接口不是在XSD中生成的。我需要写那个EXJB文件吗?请帮助有人回答吗?请阅读此主题吗?:嗨,Andrey,感谢您的回复。我正在尝试从eclipse生成xsd。这里有如何更改JAXBContext的引导(根据上面建议的链接)。我没有在这里使用任何java程序进行封送。我正在使用eclipse插件生成XSD。我在这里不知道。有人能回答吗?有人能解释一下在XSD中重新呈现接口的hiw。接口没有在XSD中生成。我需要写EXJB文件吗?请帮助