eclipse - Jersey 2 - 例如书店的最小 pom.xml,得到 404

标签 eclipse tomcat maven-2 jersey-2.0

我正在尝试运行这个例子 bookstore-webapp在带有 Tomcat 的 Eclipse 中。运行它没有问题,但是当我想用我的 pom.xml(没有父 org.glassfish.jersey.examples)从头开始构建它时,它总是返回 404。也许我是盲人,但我在文档中找不到运行它的最小 pom.xml 是什么。

我的 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>my.group.id</groupId>
    <artifactId>myartifactid</artifactId>
    <packaging>war</packaging>
    <version>1</version>
    <name>myname</name>

    <build>
        <finalName>myname</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.7</source>
                    <target>1.7</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>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.ext</groupId>
            <artifactId>jersey-mvc-jsp</artifactId>
            <version>2.14</version>
        </dependency>
        <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet</artifactId>
        <version>2.14</version>           
      </dependency> 
    </dependencies>
    <properties>
        <jersey.version>2.14</jersey.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>


</project>

最佳答案

我终于有了这个有效的 pom.xml。

注意:我在这个例子中的一个错误是我没有看到,文件夹 webapp 中的文件夹与包含 .jsp 文件的包相同。

<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>my.group.id</groupId>
<artifactId>artifactid</artifactId>
<packaging>war</packaging>
<version>1</version>
<name>name</name>

<build>
    <finalName>name</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.7</source>
                <target>1.7</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>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.4</version>
    </dependency>

    <dependency>
        <groupId>org.glassfish.jersey.ext</groupId>
        <artifactId>jersey-mvc-jsp</artifactId>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

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

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

    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-moxy</artifactId>
    </dependency>

</dependencies>
<properties>
    <jersey.version>2.14</jersey.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

关于eclipse - Jersey 2 - 例如书店的最小 pom.xml,得到 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27553563/

相关文章:

tomcat - 从 WEB-INF/lib/*.jar!/META-INF/resources 间歇加载

java - 无法使用 Eclipse 调试 Web 应用程序

java - 将 java 项目转换为 apache-tomcat 托管项目

java - Hudson 没有意识到我在构建后执行了任何测试 - 有什么想法吗?

java - 使用资源文件

android - 如何使用自定义 Intent 从 eclipse 启动 android Activity

eclipse - 如何将 IDE 配置文件保留在代码存储库之外?

java - 马文 : how to filter the same resource multiple times with different property values?

java - 下载宠物护理应用程序,帮助运行它

eclipse - 为什么 Mylyn 没有从 GitHub 收到问题?