java + eclipse + tomcat 8.5 + mavenを使用してジャージRESTアプリケーション(helloworld)を作成しました。静的index.htmlは、サーバー上でプロジェクトを実行するとうまく動作します。しかし、404jaxrs + apache + eclipseで残りのAPIを取得中に返された404静的index.htmlはきちんと動作します
のREST APIこんにちは、世界クラスを与え、残りのエンドポイント: -
@Path("/hello")
public class MyJerseyPage{
@GET
@Produces(MediaType.TEXT_HTML)
public String sayHtmlHello() {
return "Hello from Jersey";
}
}
休憩Configクラス: -
@ApplicationPath("/api")
public class RESTConfig extends Application {
}
のpom.xml: -
<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.nagendrahegde</groupId>
<artifactId>therestproject</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>therestproject Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.26</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.26</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.26</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.26</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.26</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>servlet-api</artifactId>
<version>6.0.53</version>
</dependency>
<dependency>
<groupId>org.apache.oltu.oauth2</groupId>
<artifactId>org.apache.oltu.oauth2.client</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>com.googlecode.jsontoken</groupId>
<artifactId>jsontoken</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.bundles.repackaged</groupId>
<artifactId>jersey-guava</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<build>
<finalName>therestproject</finalName>
</build>
</project>
ウェブ。 xml: -
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
出力: -
に乗る:http://localhost:8080/therestproject/api/hello - オリジンサーバがターゲットリソースの現在の表現が見つからないか、それが存在する開示して喜んではありませんでした - > 404。
前に働いていた同じセットアップは、のpom.xmlは、依存関係のバージョンの下に持っていた: -
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>servlet-api</artifactId>
<version>6.0.44</version>
</dependency>
ITが働いていました! POM.XMLを変更したときに404をスクロールして、JERSEYバージョンを最長に変更しました。 私はこれの上にoauth2をしなければならないので、私は最新のジャージーバージョンを維持したい。助けてください。