白标错误页面,类型:未找到状态:404

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

我们最近将我们的春季启动版本从1.5.10升级到2.1.2,我遇到了一个问题。当服务部署在j boss服务器上时,它表示服务未找到并且当我通过https://host:port/serviceName/swagger-ui.html在swagger中调用服务时抛出白标错误页错误但是如果我调用https://host:port/swagger-ui.html我可以访问该服务并且一切正常。有人可以让我知道会出现什么问题。感谢您的帮助。

pom.xml或bootstrap.yml没有任何变化,我刚刚升级了spring boot版本。其他一切都和以前一样。

下面是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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.goo.foo</groupId>
    <artifactId>security-service</artifactId>
    <version>1.2.3</version>
    <properties>
        <dep.scope>compile</dep.scope>
        <java.version>1.8</java.version>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.source>1.8</maven.compiler.source>
        <ojdbc.version>12.1.0.2</ojdbc.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <springfox-version>2.6.1</springfox-version>
        <config.version>2.1.0.RELEASE</config.version>
        <admin.version>2.1.0</admin.version>
        <consul-starter.version>2.1.0.RELEASE</consul-starter.version>
        <cloud-consul.version>2.1.0.RELEASE</cloud-consul.version>
    </properties>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.2.RELEASE</version>
        <relativePath />
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-consul-dependencies</artifactId>
            <version>${cloud-consul.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <!--SpringFox dependencies -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>${springfox-version}</version>
            <scope>${dep.scope}</scope>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>${springfox-version}</version>
            <scope>${dep.scope}</scope>
        </dependency>
        <dependency>
            <groupId>org.owasp.esapi</groupId>
            <artifactId>esapi</artifactId>
            <version>2.1.0</version>
        </dependency>
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt</artifactId>
            <version>0.7.0</version>
        </dependency>
        <!-- Oracle JDBC driver -->
        <dependency>
            <groupId>com.oracle.jdbc</groupId>
            <artifactId>ojdbc7</artifactId>
            <version>${ojdbc.version}</version>
            <scope>${dep.scope}</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
        </dependency>
        <!-- Consul properties -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-consul-all</artifactId>
            <version>${consul-starter.version}</version>
        </dependency>
        <!-- Spring config server - external properties -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-client</artifactId>
            <version>${config.version}</version>
        </dependency>

        <!-- Spring boot admin client - monitoring the purpose -->
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-client</artifactId>
            <version>${admin.version}</version>
        </dependency>

    <!--  jedis cache  -->
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
maven spring-boot java-8 swagger-2.0
1个回答
0
投票

好像你“迷失”了你的context-path。我猜你以前用某种形式使用现已弃用的server.contextPath=/serviceName来指定它。有几种方法可以设置它,但我这样做是在application.yaml中配置它

server:
  servlet:
    context-path: serviceName

或者application.properties

server.servlet.context-path=/serviceName

或者您可以通过将其指定为命令行参数来设置上下文路径

java -jar app.jar --server.servlet.context-path=/serviceName

这只是一些可用的选项。弄清楚如何设置它并用server.servlet.context-path替换它

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