我在服务器上使用JAR文件部署了我的Spring Boot Project,并且可以访问它

发布于 2025-02-09 00:28:44 字数 5804 浏览 0 评论 0原文

我在Lightsail Server上使用JAR文件部署了Spring Boot Project。我认为它部署正常,但是我无法访问它。

Chrome说, 无法到达该站点{IP}拒绝连接。 尝试:

检查连接 检查代理和防火墙 err_connection_refused

内部tomcat日志


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.7.0)

2022-06-21 05:37:40.476  INFO 7028 --- [           main] com.--Application        : Starting MyApplication using Java 17.0.3 on ip-172-26-7-171 with PID 7028 (/home/ubuntu/My.jar started by root in /home/ubuntu)
2022-06-21 05:37:40.483  INFO 7028 --- [           main] com.--Application        : The following 1 profile is active: "prod"
2022-06-21 05:37:42.758  INFO 7028 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-06-21 05:37:42.883  INFO 7028 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 100 ms. Found 1 JPA repository interfaces.
2022-06-21 05:37:44.472  INFO 7028 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 80 (http)
2022-06-21 05:37:44.501  INFO 7028 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-06-21 05:37:44.502  INFO 7028 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.63]
2022-06-21 05:37:44.694  INFO 7028 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-06-21 05:37:44.695  INFO 7028 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3508 ms
2022-06-21 05:37:45.661  INFO 7028 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2022-06-21 05:37:46.006  INFO 7028 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2022-06-21 05:37:46.121  INFO 7028 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2022-06-21 05:37:46.275  INFO 7028 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.6.9.Final
2022-06-21 05:37:46.658  INFO 7028 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2022-06-21 05:37:46.910  INFO 7028 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL55Dialect
2022-06-21 05:37:48.039  INFO 7028 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2022-06-21 05:37:48.055  INFO 7028 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2022-06-21 05:37:48.995  WARN 7028 --- [           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
2022-06-21 05:37:49.637  WARN 7028 --- [           main] org.thymeleaf.templatemode.TemplateMode  : [THYMELEAF][main] Template Mode 'HTML5' is deprecated. Using Template Mode 'HTML' instead.
2022-06-21 05:37:50.173  INFO 7028 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@3d1f558a, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@6abdec0e, org.springframework.security.web.context.SecurityContextPersistenceFilter@3762c4fc, org.springframework.security.web.header.HeaderWriterFilter@4b4ee511, org.springframework.security.web.csrf.CsrfFilter@38f77cd9, org.springframework.security.web.authentication.logout.LogoutFilter@2ae62bb6, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@5762658b, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@6ca372ef, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter@28f4f300, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@6aa3bfc, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@59fbb34, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@1b6924cb, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@2b5c4f17, org.springframework.security.web.session.SessionManagementFilter@5a034157, org.springframework.security.web.access.ExceptionTranslationFilter@4483d35, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@6fc1020a]
2022-06-21 05:37:50.300  INFO 7028 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 80 (http) with context path ''
2022-06-21 05:37:50.332  INFO 7028 --- [           main] com.--Application        : Started MyApplication in 10.965 seconds (JVM running for 12.248)

这是我在Lightsail上的防火墙设置。

/home/ubuntu# lsof -i -nP | grep LISTEN | awk '{print $(NF-1)" "$1}' | sort -u
*:22 sshd
127.0.0.1:33060 ssh
127.0.0.1:80 java
127.0.0.53:53 systemd-r

我必须编辑防火墙设置吗?

I deployed my spring boot project with jar file on my lightsail server. I think it deployed fine however, I can't access it.

Chrome says,
This site can’t be reached {ip} refused to connect.
Try:

Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED

internal tomcat log


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.7.0)

2022-06-21 05:37:40.476  INFO 7028 --- [           main] com.--Application        : Starting MyApplication using Java 17.0.3 on ip-172-26-7-171 with PID 7028 (/home/ubuntu/My.jar started by root in /home/ubuntu)
2022-06-21 05:37:40.483  INFO 7028 --- [           main] com.--Application        : The following 1 profile is active: "prod"
2022-06-21 05:37:42.758  INFO 7028 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-06-21 05:37:42.883  INFO 7028 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 100 ms. Found 1 JPA repository interfaces.
2022-06-21 05:37:44.472  INFO 7028 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 80 (http)
2022-06-21 05:37:44.501  INFO 7028 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-06-21 05:37:44.502  INFO 7028 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.63]
2022-06-21 05:37:44.694  INFO 7028 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-06-21 05:37:44.695  INFO 7028 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3508 ms
2022-06-21 05:37:45.661  INFO 7028 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2022-06-21 05:37:46.006  INFO 7028 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2022-06-21 05:37:46.121  INFO 7028 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2022-06-21 05:37:46.275  INFO 7028 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.6.9.Final
2022-06-21 05:37:46.658  INFO 7028 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2022-06-21 05:37:46.910  INFO 7028 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL55Dialect
2022-06-21 05:37:48.039  INFO 7028 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2022-06-21 05:37:48.055  INFO 7028 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2022-06-21 05:37:48.995  WARN 7028 --- [           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
2022-06-21 05:37:49.637  WARN 7028 --- [           main] org.thymeleaf.templatemode.TemplateMode  : [THYMELEAF][main] Template Mode 'HTML5' is deprecated. Using Template Mode 'HTML' instead.
2022-06-21 05:37:50.173  INFO 7028 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@3d1f558a, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@6abdec0e, org.springframework.security.web.context.SecurityContextPersistenceFilter@3762c4fc, org.springframework.security.web.header.HeaderWriterFilter@4b4ee511, org.springframework.security.web.csrf.CsrfFilter@38f77cd9, org.springframework.security.web.authentication.logout.LogoutFilter@2ae62bb6, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@5762658b, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@6ca372ef, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter@28f4f300, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@6aa3bfc, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@59fbb34, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@1b6924cb, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@2b5c4f17, org.springframework.security.web.session.SessionManagementFilter@5a034157, org.springframework.security.web.access.ExceptionTranslationFilter@4483d35, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@6fc1020a]
2022-06-21 05:37:50.300  INFO 7028 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 80 (http) with context path ''
2022-06-21 05:37:50.332  INFO 7028 --- [           main] com.--Application        : Started MyApplication in 10.965 seconds (JVM running for 12.248)

This is my firewall settings on lightsail.
enter image description here

/home/ubuntu# lsof -i -nP | grep LISTEN | awk '{print $(NF-1)" "$1}' | sort -u
*:22 sshd
127.0.0.1:33060 ssh
127.0.0.1:80 java
127.0.0.53:53 systemd-r

Do I have to edit firewall setting?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉世弥音 2025-02-16 00:28:45

我从application.properties中删除server.address = localhost,效果很好。

I remove server.address=localhost from application.properties and it works well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文