Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
resteasy javax.ws.rs.NotFoundException:找不到完整路径的资源 条件_Rest_Maven_Tomcat_Resteasy - Fatal编程技术网

resteasy javax.ws.rs.NotFoundException:找不到完整路径的资源 条件

resteasy javax.ws.rs.NotFoundException:找不到完整路径的资源 条件,rest,maven,tomcat,resteasy,Rest,Maven,Tomcat,Resteasy,1.resteasy 3.0.4.最终版 2.日食 3.maven 行动 我将war软件包放入tomcat7(窗口x64)webapps,服务器正常运行。 访问并在浏览器中打印“Restful示例:hello”。 但是当我在eclipse中构建tomcat7:运行tomcat7 maven插件时,请访问相同的url: javax.ws.rs.NotFoundException: Could not find resource for full path 来源(web.xml) 猜想 我认为源

1.resteasy 3.0.4.最终版
2.日食
3.maven

行动 我将war软件包放入tomcat7(窗口x64)webapps,服务器正常运行。
访问并在浏览器中打印“Restful示例:hello”。
但是当我在eclipse中构建tomcat7:运行tomcat7 maven插件时,请访问相同的url:

 javax.ws.rs.NotFoundException: Could not find resource for full path
来源(web.xml) 猜想
  • 我认为源代码是正确的,因为在单个Tomcat7服务器上成功运行war包。可能在
    pom.xml
    中缺少一些依赖项

  • 谢谢

    分析每个POM依赖项的文章真的很长……但为什么不按照官方resteasy团队的建议,尝试用这种方式编译maven呢

    mvn清洁安装
    mvn码头:运行

    <!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 version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
      <display-name>Archetype Created Web Application</display-name>
    
      <!-- Auto scan REST service -->
        <context-param>
            <param-name>resteasy.scan</param-name>
            <param-value>true</param-value>
        </context-param>
    
        <!-- this need same with resteasy servlet url-pattern -->
        <context-param>
            <param-name>resteasy.servlet.mapping.prefix</param-name>
            <param-value>/rest</param-value>
        </context-param>
    
        <servlet>
            <servlet-name>resteasy-servlet</servlet-name>
            <servlet-class>
                org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
            </servlet-class>
        </servlet>
    
        <servlet-mapping>
            <servlet-name>resteasy-servlet</servlet-name>
            <url-pattern>/rest/*</url-pattern>
        </servlet-mapping>
    
    </web-app>
    
    <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>top.crowley.rest</groupId>
        <artifactId>resteasy</artifactId>
        <packaging>war</packaging>
        <version>0.0.1-SNAPSHOT</version>
        <name>resteasy 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>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>3.1.0</version>
                <scope>provided</scope>
            </dependency>
                    <dependency>
                <groupId>javax</groupId>
                <artifactId>javaee-api</artifactId>
                <version>7.0</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.resteasy</groupId>
                <artifactId>resteasy-servlet-initializer</artifactId>
                <version>3.0.4.Final</version>
            </dependency>
            <dependency>
                <groupId>org.jboss.resteasy</groupId>
                <artifactId>resteasy-jaxrs</artifactId>
                <version>3.0.4.Final</version>
            </dependency>
        </dependencies>
        <build>
            <finalName>test-resteasy</finalName>
            <plugins>
                <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.1</version>
                    <configuration>
                        <port>8080</port>
                        <path>/test-resteasy</path>
                        <uriEncoding>UTF-8</uriEncoding>
                        <finalName>test resteasy</finalName>
                        <server>tomcat7</server>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </project>
    
    package top.crowley.resteasy;
    
    import javax.ws.rs.GET;
    import javax.ws.rs.Path;
    import javax.ws.rs.PathParam;
    import javax.ws.rs.core.Response;
    
    @Path("/message")
    public class MessageRestService {
        @GET
        @Path("/{param}")
        public Response printMessage(@PathParam("param") String msg) {
    
            String result = "Restful example : " + msg;
    
            return Response.status(200).entity(result).build();
    
        }
    
    }