成功地在azure上部署restful api但在遇到url时总是返回404错误

问题描述 投票:0回答:1

在我的项目中,我成功地在azure上部署了jersey api,并将ROOT.war文件放在/ wwwroot / webapps中,并且tomcat成功提取文件并在此目录中显示所有项目内容。但是应用程序总是回归404,我不知道为什么。这是我的pom.xml文件:

 <groupId>patientinformationdisplayer</groupId>
<artifactId>pom</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.glassfish.jersey</groupId>
            <artifactId>jersey-bom</artifactId>
            <version>2.28</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <inherited>true</inherited>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>

        <plugin>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>azure-webapp-maven-plugin</artifactId>
    <version>1.5.3</version>
    <configuration>
        <!-- App information -->
        <resourceGroup>team19backend</resourceGroup>
        <appName>team19backend</appName>
        <region>UK south</region>

        <!-- Java Runtime Stack for App on Linux-->
        <linuxRuntime>tomcat 8.5-jre8</linuxRuntime>
    </configuration>
</plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>java</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <mainClass>HoloBackend.Main</mainClass>
            </configuration>
        </plugin>
    </plugins>
</build>

我不知道部署发生了什么,我花了一整天的时间来做这件事。请帮我解决这个问题,非常感谢你。

java azure tomcat deployment
1个回答
0
投票

如果将应用程序部署到本地Tomcat,是否可以使用root URL访问该站点?推荐的方法来删除开箱即用的ROOT /目录。请仔细检查您是否已经这样做了。

您可能还想参考http://tomcat.apache.org/tomcat-7.0-doc/config/context.html,其中指出:

此Web应用程序的上下文路径,与每个请求URI的开头匹配,以选择适当的Web应用程序进行处理。特定主机中的所有上下文路径必须是唯一的。如果指定空字符串(“”)的上下文路径,则表示您正在为此主机定义默认Web应用程序,该应用程序将处理未分配给其他上下文的所有请求。只有在server.xml中静态定义Context时,才能使用此属性。在所有其他情况下,将从用于.xml上下文文件或docBase的文件名推断出该路径。

即使在server.xml中静态定义Context,也不能设置此属性,除非docBase不在Host的appBase下,或者deployOnStartup和autoDeploy都是false。如果未遵循此规则,则可能会导致双重部署。

这个链接(http://stackoverflow.com/questions/16160565/configure-the-path-localhost-of-the-war-application-to-be-the-root-java-ee)可以帮助你。

希望能帮助到你。

© www.soinside.com 2019 - 2024. All rights reserved.