【问题标题】:Index page doesn't work but api works on AWS beanstalk Sprint Boot索引页面不起作用,但 api 适用于 AWS beanstalk Spring Boot
【发布时间】:2019-02-19 19:06:42
【问题描述】:

我正在尝试将 Spring Boot 应用程序部署到 aws。

我通过 application.properties 将端口更改为 5000 现在,url/api/hello 工作正常,但 url/ 不起作用

我收到一个白标错误。

package com.example.package-name;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;

@EnableAutoConfiguration
@SpringBootApplication
@ComponentScan()
public class DemoApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

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.example</groupId>
    <artifactId>package-name</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>demo</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

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


</project>

谁能告诉我如何解决这个问题? 主 Starter 文件有什么问题吗?

注意:本地一切正常,正在加载错误页面 仅在 AWS 中的索引页

【问题讨论】:

    标签: java spring amazon-web-services spring-boot amazon-elastic-beanstalk


    【解决方案1】:

    我假设您部署在 aws elastic beanstalk tomcat 服务器中,请确保通过 beanstalk URL 访问,这将在上传 jar/war 后为您提供,通常当您尝试访问错误的 URL/错误参数时,空白错误会给您,如果可能提供带有屏幕截图的详细信息。

    【讨论】:

      猜你喜欢
      • 2016-04-02
      • 2017-09-08
      • 1970-01-01
      • 1970-01-01
      • 2017-11-15
      • 2018-07-14
      • 2022-01-26
      • 2016-08-27
      • 1970-01-01
      相关资源
      最近更新 更多