【随手记录】关于yml环境变量未配置,导致项目启动报NPE错误
docker-compose启动容器时候报错:
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'eurekaClient' defined in class path resource [org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration$EurekaClientConfiguration.class]: Unsatisfied dependency expressed through method 'eurekaClient' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'eurekaApplicationInfoManager' defined in class path resource [org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration$EurekaClientConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.netflix.appinfo.ApplicationInfoManager]: Factory method 'eurekaApplicationInfoManager' threw exception; nested exception is java.lang.NullPointerException
主要原因是docker-compose.yml文件里设置的环境变量没有找到对应的值,默认赋空 导致启动报错!
把环境变量值设置即可解决