簡體   English   中英

AWS Elastic Beanstalk-Tomcat Java Spring Boot應用程序出現問題

[英]AWS Elastic Beanstalk - Problem with tomcat java spring boot application

您是否知道我無法訪問Amazon Elastic Beanstalk上托管的應用程序的內容?

配置:在64位Amazon Linux / 3.0.6上運行Java 8的Tomcat 8.5我的應用程序:Java spring boot應用程序

在我的本地主機上,一切正常。

我在application.properties文件中設置了server.port = 5000。

當我嘗試使用鏈接獲取我的應用登錄頁面時:

http://testenv-env.eu-west-1.elasticbeanstalk.com/employee/login

我收到了404錯誤消息:

HTTP狀態404 –找不到類型狀態報告

消息/員工/登錄

但是當我向鏈接添加端口時:

http://testenv-env.eu-west-1.elasticbeanstalk.com:5000/employee/login

錯誤是:無法訪問此站點。

我的安全組配置:

在此處輸入圖片說明

/var/log/tomcat8/localhost_access_log.txt

127.0.0.1 - - [17/Nov/2018:10:19:04 +0000] "GET / HTTP/1.1" 404 1074
127.0.0.1 - - [17/Nov/2018:10:21:16 +0000] "GET /employee/login HTTP/1.1" 404 1092
127.0.0.1 - - [17/Nov/2018:10:29:02 +0000] "GET / HTTP/1.1" 404 1074
127.0.0.1 - - [17/Nov/2018:10:29:56 +0000] "GET /employee/login HTTP/1.1" 404 1092

在/ var /日志/的httpd / error_log中

[Sat Nov 17 10:19:18.529071 2018] [mpm_worker:notice] [pid 3716:tid 140569196038208] AH00295: caught SIGTERM, shutting down
[Sat Nov 17 10:19:22.241929 2018] [ssl:warn] [pid 25414:tid 140137380542528] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Sat Nov 17 10:19:22.243341 2018] [mpm_worker:notice] [pid 25414:tid 140137380542528] AH00292: Apache/2.4.34 (Amazon) OpenSSL/1.0.2k-fips configured -- resuming normal operations
[Sat Nov 17 10:19:22.243372 2018] [core:notice] [pid 25414:tid 140137380542528] AH00094: Command line: '/usr/sbin/httpd'

和我的pom.xml依賴項:

<groupId>com.project</groupId>
    <artifactId>iam</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

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

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.0.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-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

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

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
 <groupId>org.apache.tomcat.embed</groupId>
 <artifactId>tomcat-embed-jasper</artifactId>
</dependency>

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

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
<dependency>
 <groupId>org.webjars</groupId>
 <artifactId>bootstrap</artifactId>
 <version>4.0.0</version>
</dependency>


    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
    </dependency>


    </dependencies>

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

第一步是檢查您的網址

http://iam-env.eu-west-1.elasticbeanstalk.com/employee/login

本身看起來不正確。 這太籠統了,是不對的。 建議您查找“ AWS Beanstalk所有應用程序”屏幕。 在正確環境右側顯示的框中,您會找到您的URL,該URL類似於以下內容

https://test-env.asu2mcXXrr.eu-west-2.elasticbeanstalk.com

@ michal9225您只需要設置“路由”即可。 發生的是beantalk URL,它期望您的應用程序在端口80上運行,並且在本地系統中開發應用程序時,我們通常會更改端口,因為其他應用程序或服務可能會在大多數常見端口上運行。

所以現在您有兩個選擇:

1-設置負載均衡器並將5000端口路由到80,然后通過負載均衡器URL訪問應用程序

2-將Application.property文件中的端口從5000更改為80(server.port = 80)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM