【问题标题】:AWS - Spring boot/Angular deployment to elastic beanstalk connecting to rds database instanceAWS - Spring boot/Angular 部署到连接到 rds 数据库实例的弹性 beanstalk
【发布时间】:2020-11-30 15:52:25
【问题描述】:

在将 spring-boot 部署到弹性 beanstalk 上时,我无法将它连接到 rds 数据库实例。我遵循了指南https://www.devglan.com/spring-boot/spring-boot-angular-deployment,它帮助我将我的应用程序转换为 jar 文件,然后将其部署到弹性 beanstalk 上。问题是,当我从命令行(本地)运行 jar 文件时,该项目工作得非常好,但是一旦我将 jar 文件上传到弹性 beanstalk 并转到 URL,它似乎没有连接到 rds . 但是,我确实知道,这可能是因为我的 Angular 应用程序中的基本 URL 和搜索 URL,因为在我的打字稿文件中,我的 URL 是

private baseUrl = "http://localhost:8080/api/products";
private search = "http://localhost:8080/api/product-category";

在网络控制台中,我收到了

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8080/api/product-category. (Reason: CORS request did not succeed).

但我不确定将 URL 的“localhost:8080”部分更改为什么。如果我应该提供其他任何东西,请随时告诉我。我还想补充一点,我确实在提供的 URL 上看到了我的 Angular 应用程序,但该网站似乎没有从数据库中检索。 谢谢

【问题讨论】:

    标签: angular amazon-web-services spring-boot amazon-rds


    【解决方案1】:

    如果有人也遇到这个麻烦: 我在 application.properties 文件中配置了 server.port = 5000 我转到我的角度并将链接 http://localhost:8080 更改为 {aws 提供的 url}/api/products 和另一个链接 如果我想进行任何更改,我将我的 angular url 更改为 localhost:5000。

    所以我添加了一个 if 语句,如果我在本地工作,则将 url 初始化为 localhost:5000,否则如果我将 Web 应用程序部署到弹性 beanstalk 上,则更改为 {aws provided url}。

    总的来说:事实证明我正在连接到数据库,但我没有正确配置我的角度链接,因此我没有从正确的链接中检索。

    【讨论】:

      猜你喜欢
      • 2019-07-05
      • 2017-05-22
      • 2016-02-15
      • 1970-01-01
      • 2013-01-28
      • 2015-01-25
      • 2014-05-03
      • 2018-11-25
      • 1970-01-01
      相关资源
      最近更新 更多