0

我已经使用 Maven 创建了 Spring Boot 应用程序。我为应用程序构建了一个可执行 jar,尝试使用以下命令在 EC2 实例免费层窗口上运行它
java -jar com-spring-boot-apps-0.0.1-SNAPSHOT.jar --server.port=8181 -Xdebug

有些应用程序没有运行,它存在于控制台上的以下日志中。

log4j:WARN No appenders could be found for logger (org.springframework.web.context.support.StandardServletEnvironment).
log4j:WARN Please initialize the log4j system properly.

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

2018-07-11 13:55:50.762  INFO 2784 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-07-11 13:55:50.768  INFO 2784 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.31
2018-07-11 13:55:50.800  INFO 2784 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : Loaded APR based Apache Tomcat Native library [1.2.17] using APR version [1.6.3].
2018-07-11 13:55:50.803  INFO 2784 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2018-07-11 13:55:50.805  INFO 2784 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
2018-07-11 13:55:52.060  INFO 2784 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : OpenSSL successfully initialized [OpenSSL 1.0.2o  27 Mar 2018]
2018-07-11 13:55:52.402  INFO 2784 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-07-11 13:55:52.532  INFO 2784 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]

例外 :-

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'regionProvider': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.aws.core.region.StaticRegionProvider]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: The region 'ap-south-1a' is not a valid region!
4

6 回答 6

1

commons-logging 与 log4j 有冲突。我已经多次遇到这个问题,每次排除公共日志记录都帮助我解决了这个问题。推荐检查依赖树。

mvn dependency:tree > module-dependency.txt

然后在您看到的任何地方排除 commons-loggin

            <exclusions>
            <exclusion>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache</groupId>
                <artifactId>commons-io</artifactId>
            </exclusion>
        </exclusions>
于 2020-11-22T17:55:03.900 回答
0

区域“ap-south-1a”是不正确的区域。在我看来,它应该是“ap-south-1”。您可以检查 .aws 目录中的配置文件以查看是否正确设置了区域。还要检查环境变量 AWS_DEFAULT_REGION 是否设置正确。

https://docs.aws.amazon.com/general/latest/gr/rande.html

于 2018-07-12T06:01:31.930 回答
0

从 application.properties 和 pom.xml 属性中删除 cloud.aws.region.static=ap-south-1a 后,它对我有用。

但同时,如果我从本地机器项目设置中删除此属性,则会失败并出现以下错误。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'amazonS3': Invocation of init method failed; nested exception is java.lang.IllegalStateException: There is no EC2 meta data available, because the application is not running in the EC2 environment. Region detection is only possible if the application is running on a EC2 instance
于 2018-07-12T06:51:50.690 回答
0

如果启用了端点,您可以通过 JMX 或 HTTP 正确关闭应用程序(将 endpoints.shutdown.enabled=true 添加到 application.properties 文件)。

/shutdown - 让应用程序正常关闭。(默认情况下未启用)。

来自Spring Boot 文档

于 2018-07-11T13:17:54.407 回答
0

您的地区名称正确吗?

https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RegionsAndAvailabilityZones.html

于 2018-07-12T05:22:41.937 回答
0

就我而言, pom.xml 文件中缺少日志记录框架。我使用的是 spring-boot-starter-parent 版本 2.2.5.RELEASE。为了解决应用程序未启动的问题,我在 pom.xml 中添加了以下内容:

<dependency>
        <artifactId>logback-classic</artifactId>
        <groupId>ch.qos.logback</groupId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
于 2021-07-08T13:27:25.120 回答