Веб-сервис отдыха, выдающий внутреннюю ошибку сервера - PullRequest
0 голосов
/ 03 марта 2020

Привет всем, я пытаюсь узнать REST API, используя Джерси. У меня есть следующий код. Я не могу определить, где находится ошибка. Я приложил java используемые мной классы, а также файл pom из проекта maven. Любая помощь будет оценена [введите описание изображения здесь] [1]

`

человек ресурс: https://pastebin.com/raw/z0X2A6eA

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;


@Path("pers")
public class personResource {

    @GET
    @Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
    public person getcustomer() {

        person a1 = new person();
        a1.setName("george");
        a1.setNumber(12);

        return a1;
    } 

}

класс человек : https://pastebin.com/raw/WQvZrVmZ

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class person {

    private String name;
    private int number;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        System.out.println("setting name");
        this.name = name;
    }
    public int getNumber() {
        return number;
    }
    public void setNumber(int number) {
        System.out.println("setting numb");
        this.number = number;
    }

}

пом. xml: https://pastebin.com/raw/6WAtruqK

  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.test</groupId>
    <artifactId>learning</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>learning</name>

    <build>
        <finalName>learning</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <inherited>true</inherited>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.glassfish.jersey</groupId>
                <artifactId>jersey-bom</artifactId>
                <version>${jersey.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet-core</artifactId>
            <!-- use the following artifactId if you don't need servlet 2.x compatibility -->
            <!-- artifactId>jersey-container-servlet</artifactId -->
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.inject</groupId>
            <artifactId>jersey-hk2</artifactId>
        </dependency>
        <!-- uncomment this to get JSON support
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-binding</artifactId>
        </dependency>
        -->
    </dependencies>
    <properties>
        <jersey.version>2.30.1</jersey.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
</project>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...