我已经使用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!
答案 0 :(得分:0)
如果启用了端点,则可以通过JMX或HTTP正确关闭应用程序(将endpoints.shutdown.enabled = true添加到application.properties文件中)。
/ shutdown-使应用程序正常关闭。 (默认情况下未启用)。
答案 1 :(得分:0)
您的地区名称正确吗?
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RegionsAndAvailabilityZones.html
答案 2 :(得分:0)
区域“ ap-south-1a”是错误的区域。我认为它应该是“ ap-south-1”。您可以检查.aws目录中的配置文件,以查看是否正确设置了区域。还要检查环境变量AWS_DEFAULT_REGION是否正确(如果设置)。
答案 3 :(得分: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
答案 4 :(得分:0)
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>
答案 5 :(得分: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>