在AWS Beanstalk上部署SpringBoot - 应用程序启动,连接到RDS-DB,但浏览器无法连接。

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

我现在正在学习AWS,因此现在将我的spring boot应用部署在AWS Elasctic Beanstalk上,并将其连接到我放在AWS RDS上的mariaDB数据库。这很成功! 我可以看到我的数据库中的测试条目,而且Elastic Beanstalk日志文件也显示Spring应用已经启动,健康检查也是OK的。

但是当我点击App的链接时 studileih.eu-central-1.elasticbeanstalk.com我得到一个404.我也试过 studileih.eu-central-1.elasticbeanstalk.com5000因为我的spring boot应用是在5000端口启动的(我把它从8080改成5000,因为我认为ElasticBeanstalk需要5000端口?studileih.eu-central-1.elasticbeanstalk.com所有产品。studileih.eu-central-1.elasticbeanstalk.com5000所有产品。 因为allProducts是我get请求的端点。

Elastic Beanstalk Health Check

Jun 12 17:42:41 ip-172-31-14-223 web: .   ____          _            __ _ _
Jun 12 17:42:41 ip-172-31-14-223 web: /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
Jun 12 17:42:41 ip-172-31-14-223 web: ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
Jun 12 17:42:41 ip-172-31-14-223 web: \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
Jun 12 17:42:41 ip-172-31-14-223 web: '  |____| .__|_| |_|_| |_\__, | / / / /
Jun 12 17:42:41 ip-172-31-14-223 web: =========|_|==============|___/=/_/_/_/
Jun 12 17:42:41 ip-172-31-14-223 web: :: Spring Boot ::        (v2.2.7.RELEASE)
Jun 12 17:42:41 ip-172-31-14-223 web: 2020-06-12 17:42:41.459  INFO 4050 --- [           main]     
c.e.studileih.StudileihApplication       : Starting StudileihApplication v0.0.1-SNAPSHOT on     
ip-172-31-14-223.eu-central-1.compute.internal with PID 4050 (/var/app/current/application.jar 
started by webapp in /var/app/current)
Jun 12 17:42:41 ip-172-31-14-223 web: 2020-06-12 17:42:41.471  INFO 4050 --- [           main] 
c.e.studileih.StudileihApplication       : No active profile set, falling back to default profiles:   
default
Jun 12 17:42:43 ip-172-31-14-223 web: 2020-06-12 17:42:43.721  INFO 4050 --- [           main] 
.s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT 
mode.
Jun 12 17:42:43 ip-172-31-14-223 web: 2020-06-12 17:42:43.912  INFO 4050 --- [           main] 
 .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 164ms. Found 
2 JPA repository interfaces.
Jun 12 17:42:45 ip-172-31-14-223 web: 2020-06-12 17:42:45.720  INFO 4050 --- [           main] 
o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 5000 (http)
Jun 12 17:42:45 ip-172-31-14-223 web: 2020-06-12 17:42:45.751  INFO 4050 --- [           main] 
o.apache.catalina.core.StandardService   : Starting service [Tomcat]
Jun 12 17:42:45 ip-172-31-14-223 web: 2020-06-12 17:42:45.752  INFO 4050 --- [           main] 
org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.34]
Jun 12 17:42:45 ip-172-31-14-223 web: 2020-06-12 17:42:45.967  INFO 4050 --- [           main] 
o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
Jun 12 17:42:45 ip-172-31-14-223 web: 2020-06-12 17:42:45.970  INFO 4050 --- [           main] 
o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in  
4339 ms
Jun 12 17:42:47 ip-172-31-14-223 web: 2020-06-12 17:42:47.014  INFO 4050 --- [           main] 
o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
Jun 12 17:42:47 ip-172-31-14-223 web: 2020-06-12 17:42:47.140  INFO 4050 --- [           main] 
org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.15.Final
Jun 12 17:42:47 ip-172-31-14-223 web: 2020-06-12 17:42:47.475  INFO 4050 --- [           main] 
o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
Jun 12 17:42:47 ip-172-31-14-223 web: 2020-06-12 17:42:47.742  INFO 4050 --- [           main] 
com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
Jun 12 17:42:47 ip-172-31-14-223 web: 2020-06-12 17:42:47.932  INFO 4050 --- [           main] 
com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
Jun 12 17:42:47 ip-172-31-14-223 web: 2020-06-12 17:42:47.979  INFO 4050 --- [           main] 
org.hibernate.dialect.Dialect            : HHH000400: Using dialect: 
org.hibernate.dialect.MariaDB53Dialect
Jun 12 17:42:48 ip-172-31-14-223 web: 2020-06-12 17:42:48.207  WARN 4050 --- [           main] 
org.hibernate.cfg.AnnotationBinder       : HHH000503: A class should not be annotated with both 
@Inheritance and @MappedSuperclass. @Inheritance will be ignored for: 
com.example.studileih.Entity.BaseEntity.
Jun 12 17:42:49 ip-172-31-14-223 web: 2020-06-12 17:42:49.638  INFO 4050 --- [           main] 
org.hibernate.tuple.PojoInstantiator     : HHH000182: No default (no-argument) constructor for 
class: com.example.studileih.Entity.Country (class must be instantiated by Interceptor)
Jun 12 17:42:49 ip-172-31-14-223 web: 2020-06-12 17:42:49.763  INFO 4050 --- [           main] 
org.hibernate.tuple.PojoInstantiator     : HHH000182: No default (no-argument) constructor for 
class: com.example.studileih.Entity.City (class must be instantiated by Interceptor)
Jun 12 17:42:50 ip-172-31-14-223 web: 2020-06-12 17:42:50.133  INFO 4050 --- [           main] 
o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: 
[org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
Jun 12 17:42:50 ip-172-31-14-223 web: 2020-06-12 17:42:50.142  INFO 4050 --- [           main] 
j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 
'default'
Jun 12 17:42:50 ip-172-31-14-223 web: Hibernate: select `next_val` as id_val from 
`hibernate_sequence` for update
Jun 12 17:42:50 ip-172-31-14-223 web: Hibernate: update `hibernate_sequence` set `next_val`= ? where  
`next_val`=?
Jun 12 17:42:50 ip-172-31-14-223 web: Hibernate: insert into `product` (`created_at`, `updated_at`, 
`available`, `name`, `pic_paths`, `price`, `title`, `type`, `user_id`, `views`, `id`) values (?, ?, 
?, ?, ?, ?, ?, ?, ?, ?, ?)
Jun 12 17:42:51 ip-172-31-14-223 web: Hibernate: select `next_val` as id_val from 
`hibernate_sequence` for update
[... some more hibernate logs that I deleted for better readablility]
Jun 12 17:42:51 ip-172-31-14-223 web: 2020-06-12 17:42:51.295  WARN 4050 --- [           main]    
JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore,   
database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-
view to disable this warning
Jun 12 17:42:51 ip-172-31-14-223 web: 2020-06-12 17:42:51.592  INFO 4050 --- [           main] 
 o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
Jun 12 17:42:52 ip-172-31-14-223 web: 2020-06-12 17:42:52.069  INFO 4050 --- [           main] 
o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 5000 (http) with context path   
''
Jun 12 17:42:52 ip-172-31-14-223 web: 2020-06-12 17:42:52.078  INFO 4050 --- [           main] 
c.e.studileih.StudileihApplication       : Started StudileihApplication in 11.903 seconds (JVM 
running for 13.534)
Jun 12 17:43:16 ip-172-31-14-223 web: 2020-06-12 17:43:16.252  INFO 4050 --- [nio-5000-exec-1] 
o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
Jun 12 17:43:16 ip-172-31-14-223 web: 2020-06-12 17:43:16.254  INFO 4050 --- [nio-5000-exec-1] 
o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
Jun 12 17:43:16 ip-172-31-14-223 web: 2020-06-12 17:43:16.279  INFO 4050 --- [nio-5000-exec-1] 
o.s.web.servlet.DispatcherServlet        : Completed initialization in 25 ms


----------------------------------------
/var/log/nginx/access.log
----------------------------------------
77.190.237.177 - - [12/Jun/2020:17:34:32 +0000] "GET / HTTP/1.1" 404 306 "-" "Mozilla/5.0 (Windows    
NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36" "-"
77.190.237.177 - - [12/Jun/2020:17:34:33 +0000] "GET /favicon.ico HTTP/1.1" 404 143 
"http://studileih.eu-central-1.elasticbeanstalk.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64)    
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36" "-"
77.190.237.177 - - [12/Jun/2020:17:34:43 +0000] "GET /allproducts HTTP/1.1" 404 306 "-" "Mozilla/5.0     
(Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97   
Safari/537.36" "-"
77.190.237.177 - - [12/Jun/2020:17:35:26 +0000] "GET / HTTP/1.1" 404 306 "-" "Mozilla/5.0 (Windows 
 NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36" "-" 
 77.190.237.177 - - [12/Jun/2020:17:35:57 +0000] "GET / HTTP/1.1" 404 306 "-" "Mozilla/5.0 (Windows   
 NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36" "-"
77.190.237.177 - - [12/Jun/2020:17:36:05 +0000] "GET /allproducts HTTP/1.1" 404 306 "-" "Mozilla/5.0     
(Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97   
Safari/537.36" "-"
77.190.237.177 - - [12/Jun/2020:17:43:16 +0000] "GET / HTTP/1.1" 404 306 "-" "Mozilla/5.0 (Windows 
NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36" "-"
77.190.237.177 - - [12/Jun/2020:17:45:13 +0000] "GET / HTTP/1.1" 404 306 "-" "Mozilla/5.0 (Windows 
NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36" "-"
77.190.237.177 - - [12/Jun/2020:17:45:13 +0000] "GET /favicon.ico HTTP/1.1" 404 143 
"http://18.157.145.222/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like   
Gecko) Chrome/83.0.4103.97 Safari/537.36" "-"
77.190.237.177 - - [12/Jun/2020:17:45:39 +0000] "GET / HTTP/1.1" 404 306 "-" "Mozilla/5.0 (Windows 
NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36" "-"
77.190.237.177 - - [12/Jun/2020:17:45:54 +0000] "GET / HTTP/1.1" 404 306 "-" "Mozilla/5.0 (Windows 
NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36" "-"
77.190.237.177 - - [12/Jun/2020:17:46:13 +0000] "GET /5000 HTTP/1.1" 404 306 "-" "Mozilla/5.0 
(Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97   
Safari/537.36" "-" 
77.190.237.177 - - [12/Jun/2020:17:47:57 +0000] "GET / HTTP/1.1" 404 306 "-" "Mozilla/5.0 (Windows 
NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36" "-"


----------------------------------------
/var/log/nginx/error.log
----------------------------------------
(end of log)
amazon-web-services spring-boot amazon-elastic-beanstalk
1个回答
0
投票

我以为我已经将安全组入站规则设置为 "Allow All Traffic from Everywhere",但这是错误的。添加它们后,它的工作与 http:/studileih.eu-central-1.elasticbeanstalk.com所有产品。 5000端口是不需要的)奇怪的是,HTTP规则不够强硬.....:

my security group inbound rules

这是直接在浏览器中得到的结果。

result

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