Java Intellij-RestService WAR在本地部署时工作,但在远程服务器上部署404时工作

Java Intellij-RestService WAR在本地部署时工作,但在远程服务器上部署404时工作,java,tomcat,intellij-idea,http-status-code-404,war,Java,Tomcat,Intellij Idea,Http Status Code 404,War,刚刚从Eclipse转换为Intellij,不完全确定我在这里做错了什么: 当我在IDE中创建的Tomcat实例上本地部署war文件时,我可以访问所有服务/端点。一旦我从目标文件夹中取出生成的WAR并将其放到远程服务器上的webapps文件夹中,它就会停止工作。我已经向这个服务器导出了几个eclipse WAR,我仍然可以访问所有这些应用程序。在构建工件时,我是否缺少一些配置 不确定这会有多大帮助,但: web.xml Jersey Web应用程序 org.glassfish.jersey.s

刚刚从Eclipse转换为Intellij,不完全确定我在这里做错了什么:

当我在IDE中创建的Tomcat实例上本地部署war文件时,我可以访问所有服务/端点。一旦我从目标文件夹中取出生成的WAR并将其放到远程服务器上的webapps文件夹中,它就会停止工作。我已经向这个服务器导出了几个eclipse WAR,我仍然可以访问所有这些应用程序。在构建工件时,我是否缺少一些配置

不确定这会有多大帮助,但: web.xml


Jersey Web应用程序
org.glassfish.jersey.servlet.ServletContainer
jersey.config.server.provider.packages
com.valassis.rest
1.
Jersey Web应用程序
/DalimRestService/*
pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.valassis.common</groupId>
<artifactId>DalimRestService</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>DalimRestService Webapp</name>
<url>http://maven.apache.org</url>

<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>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet-core</artifactId>
    </dependency>
    <!--<dependency>-->
    <!--<groupId>com.sun.jersey</groupId>-->
    <!--<artifactId>jersey-bundle</artifactId>-->
    <!--<version>1.19.4</version>-->
    <!--</dependency>-->
</dependencies>

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

</project>

4.0.0
com.valassis.common
DalimRestService
战争
1.0-快照
DalimRestService Web应用程序
http://maven.apache.org
DalimRestService
maven编译器插件
1.8
1.8
maven资源插件
2.7
org.glassfish.jersey
针织面料
${jersey.version}
聚甲醛
进口
org.glassfish.jersey.containers
jersey容器servlet核心
2.23.2

您检查过服务器的日志了吗?另外,当访问部署到Tomcat的端点时,您使用什么URL?最新的日志表明它部署了我的应用程序。它还显示了我获取资源并返回404。我正在使用的URL是{servername}:{port}/DalimRestService/json/product/hhs/upsert/20180501/test如果我从Eclipse部署,该URL过去一直有效。请尝试此URL{servername}:{port}/DalimRestService/DalimRestService/json/product/hhs/upsert/20180501/test。一个
DalimRestService
是因为您的war的名称,而Tomcat默认情况下使用war的名称在上下文中部署war。第二个原因是web.xml中的servlet映射有效!非常感谢。我猜,如果我将URL模式更改为/*,那么我的原始URL将正常工作?问题是,当您从Eclipse部署时,它将部署到根上下文,而不是web.xml中的
DalimRestService
。所以您只需要记住Eclipse和Tomcat部署到不同的上下文中,然后您必须从web.xml追加映射
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.valassis.common</groupId>
<artifactId>DalimRestService</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>DalimRestService Webapp</name>
<url>http://maven.apache.org</url>

<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>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet-core</artifactId>
    </dependency>
    <!--<dependency>-->
    <!--<groupId>com.sun.jersey</groupId>-->
    <!--<artifactId>jersey-bundle</artifactId>-->
    <!--<version>1.19.4</version>-->
    <!--</dependency>-->
</dependencies>

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

</project>