![](/img/trans.png)
[英]Spring Boot / Tomcat on AWS Elastic Beanstalk only showing 404 page
[英]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类似于以下内容
@ michal9225您只需要设置“路由”即可。 发生的是beantalk URL,它期望您的应用程序在端口80上运行,并且在本地系统中开发应用程序时,我们通常会更改端口,因为其他应用程序或服务可能会在大多数常见端口上运行。
所以现在您有两个选择:
1-设置负载均衡器并将5000端口路由到80,然后通过负载均衡器URL访问应用程序
2-将Application.property文件中的端口从5000更改为80(server.port = 80)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.