404错误:“原始服务器找不到目标资源的当前表示形式”。我该怎么办?

时间:2018-09-06 19:46:36

标签: java tomcat intellij-idea http-status-code-404

我已经仔细阅读了我能找到的所有Stack Overflow帖子,并通过Google解决了这个问题,但无济于事。我已经在IntelliJ中建立了一个Maven项目。

当我尝试在浏览器上访问localhost:8090时,出现404错误:

  

原始服务器找不到目标资源的当前表示,或者不愿意透露其存在。

提供视觉图像。

这是工件设置:

Artifact screenshot

这是Tomcat设置:

Tomcat server tab

Tomcat deployment tab

这是网址:

http://localhost:8090/json/product/ping

这是服务代码:

package com.project.rest;
import com.project.dao.OracleJDBC;
import com.project.product.FiftyInFifty;
import com.project.product.FsiProductLine;
import com.project.product.HHSProductLine;
import com.project.product.WrapProductLine;

import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import java.util.Date;

@Path("/json/product")

public class JSONService {

    private FsiProductLine fsi = new FsiProductLine();
    private WrapProductLine wrap = new WrapProductLine();
    private HHSProductLine hhs = new HHSProductLine();
    private DalimGetPropertyValues properties = new 
    DalimGetPropertyValues();

    @GET
    @Path("ping")
    public String getServerTime() {
        System.out.println("RESTful Service 'DalimRestService' is running 
==> ping");
        return "received ping on " + new Date().toString() + "; environmen 
: " + properties.getEnvironemnt();
}}

这是我的web.xml文件:

<servlet>
    <servlet-name>Jersey Web Application</servlet-name>
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
    <init-param>
        <param-name>jersey.config.server.provider.packages</param-name>
        <param-value>com.project.rest</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Jersey Web Application</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

这是我的POM文件:

<project>

    <artifactId>DalimRestService</artifactId>
    <version>1.0-SNAPSHOT</version>

    <build>
        <finalName>DalimRestService</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>2.7</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>


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



    <dependencies>

        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet-core</artifactId>
        </dependency>


        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jaxrs</artifactId>
            <version>2.2.1.GA</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jackson-provider</artifactId>
            <version>2.2.1.GA</version>
        </dependency>

        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20180130</version>
        </dependency>

        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>javax.json</artifactId>
            <version>1.1.2</version>
        </dependency>

        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>javax.persistence</artifactId>
            <version>2.1.0</version>
        </dependency>

        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>2.1</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.2.5.Final</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>5.2.17.Final</version>
        </dependency>

        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <version>7.1.0.jre10-preview</version>
            <scope>test</scope>
        </dependency>







    </dependencies>

    <properties>
        <jersey.version>2.23.2</jersey.version>
    </properties>

我目前已将Tomcat设置为端口8090。我知道这应该很简单,但是无论我做什么,我似乎都无法使它正常工作。

0 个答案:

没有答案