Java 不包含ResourceConfig实例不包含的任何根资源类

Java 不包含ResourceConfig实例不包含的任何根资源类,java,web-services,rest,jersey,Java,Web Services,Rest,Jersey,我得到了异常com.sun.jersey.api.container.ContainerException:当我运行我的简单应用程序时,使用jersey的Restfull web服务以XML格式打印消息 web.xml: 资源类别: MessageResource.java @Path("/messages") public class MessageResource { MessageService msgService = new MessageService(); @GET @Prod

我得到了异常com.sun.jersey.api.container.ContainerException:当我运行我的简单应用程序时,使用jersey的Restfull web服务以XML格式打印消息 web.xml:

资源类别: MessageResource.java

@Path("/messages")
public class MessageResource {

MessageService msgService = new MessageService();

@GET
@Produces(MediaType.APPLICATION_XML)
public List<Message> getMessage() {
    return msgService.getAllMessages();
}
 }
@Path(“/messages”)
公共类消息资源{
MessageService msgService=newmessageservice();
@得到
@生成(MediaType.APPLICATION\u XML)
公共列表getMessage(){
返回msgService.getAllMessages();
}
}
这一例外背后的原因是什么?? 提前感谢:)


我们需要查看你的应用程序配置,即web.xml,或者如果你没有使用web.xml,那么你的Java配置中的
MessageResource
类是什么包?我们需要查看你的应用程序配置,即web.xml,或者如果你没有使用web.xml,那么您的Java配置中的
MessageResource
类是什么包?
 public class MessageService {

private Map<Long, Message> messages = DataBaseClass.getMessages();

public List<Message> getAllMessages() {
    return new ArrayList<Message>(messages.values());
   }
 }
public class DataBaseClass {

    private static Map<Long, Message> messages = new HashMap<Long, Message>();
    private static Map<Long, Profile> profiles = new HashMap<Long, Profile>();


    public static Map<Long, Message> getMessages() {
        return messages;
    }

    public static Map<Long, Profile> getProfiles() {
        return profiles;
    }
 }
 @XmlRootElement
 public class Message {

private long id;
private String message;
private Date created;
private String author;

public Message() {
    super();
}
public Message(long id, String message, String author) {
    super();
    this.id = id;
    this.message = message;
    this.author = author;
}
public long getId() {
    return id;
}
public void setId(long id) {
    this.id = id;
}
public String getMessage() {
    return message;
}
public void setMessage(String message) {
    this.message = message;
}
public Date getCreated() {
    return created;
}
public void setCreated(Date created) {
    this.created = created;
}
public String getAuthor() {
    return author;
}
public void setAuthor(String author) {
    this.author = author;
}
}
@Path("/messages")
public class MessageResource {

MessageService msgService = new MessageService();

@GET
@Produces(MediaType.APPLICATION_XML)
public List<Message> getMessage() {
    return msgService.getAllMessages();
}
 }