spring cloud config server NullPointerException
MamyA 2018-09-03 11:48:14 我在本地使用本地目录作为spring cloud config server的配置中心存储(JDK1.8),启动报空指针,找不到searchLocations的配置,配置如下:
----
server:
port: 8080
eureka:
instance:
hostname: 192.168.1.1
non-secure-port: ${server.port}
spring:
application:
name: config-server
config:
name: config-file
profiles:
active:
- native
cloud:
config:
server:
native:
version: 0.0.1
order: 1
search-locations:
- file:///E:/config
----
POM.xml配置如下:
-----
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.SR5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>compile</scope>
</dependency>
<!--eureka server -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
</dependencies>
-----
启动报错如下:
-----
2018-09-03 11:43:17.010 |-INFO [localhost-startStop-1] org.springframework.web.servlet.handler.SimpleUrlHandlerMapping [362] -| Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-03 11:43:17.010 |-INFO [localhost-startStop-1] org.springframework.web.servlet.handler.SimpleUrlHandlerMapping [362] -| Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-03 11:43:17.057 |-INFO [localhost-startStop-1] org.springframework.web.servlet.handler.SimpleUrlHandlerMapping [362] -| Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-03 11:43:17.073 |-INFO [localhost-startStop-1] org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WelcomePageHandlerMapping [549] -| Adding welcome page: ServletContext resource [/index.html]
2018-09-03 11:43:17.400 |-ERROR [localhost-startStop-1] org.springframework.boot.bind.PropertiesConfigurationFactory [350] -| Properties configuration failed validation
2018-09-03 11:43:17.400 |-ERROR [localhost-startStop-1] org.springframework.boot.bind.PropertiesConfigurationFactory [352] -| Field error in object 'spring.cloud.config.server.native' on field 'searchLocations': rejected value [null]; codes [methodInvocation.spring.cloud.config.server.native.searchLocations,methodInvocation.searchLocations,methodInvocation.[Ljava.lang.String;,methodInvocation]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [spring.cloud.config.server.native.searchLocations,searchLocations]; arguments []; default message [searchLocations]]; default message [Property 'searchLocations' threw exception; nested exception is java.lang.NullPointerException]
2018-09-03 11:43:17.416 |-ERROR [localhost-startStop-1] org.springframework.boot.bind.PropertiesConfigurationFactory [352] -| Field error in object 'spring.cloud.config.server.native' on field 'searchLocations': rejected value [null,null]; codes [methodInvocation.spring.cloud.config.server.native.searchLocations,methodInvocation.searchLocations,methodInvocation.[Ljava.lang.String;,methodInvocation]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [spring.cloud.config.server.native.searchLocations,searchLocations]; arguments []; default message [searchLocations]]; default message [Property 'searchLocations' threw exception; nested exception is java.lang.NullPointerException]
2018-09-03 11:43:17.416 |-WARN [localhost-startStop-1] org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext [551] -| Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration$$EnhancerBySpringCGLIB$$1becfed2]: Constructor threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'configServerHealthIndicator' defined in class path resource [org/springframework/cloud/config/server/config/EnvironmentRepositoryConfiguration.class]: Unsatisfied dependency expressed through method 'configServerHealthIndicator' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cloud.config.server.config.CompositeConfiguration': Unsatisfied dependency expressed through method 'setEnvironmentRepos' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'nativeEnvironmentRepository': Could not bind properties to NativeEnvironmentRepository (prefix=spring.cloud.config.server.native, ignoreInvalidFields=false, ignoreUnknownFields=true, ignoreNestedProperties=false); nested exception is org.springframework.validation.BindException: org.springframework.boot.bind.RelaxedDataBinder$RelaxedBeanPropertyBindingResult: 2 errors
Field error in object 'spring.cloud.config.server.native' on field 'searchLocations': rejected value [null]; codes [methodInvocation.spring.cloud.config.server.native.searchLocations,methodInvocation.searchLocations,methodInvocation.[Ljava.lang.String;,methodInvocation]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [spring.cloud.config.server.native.searchLocations,searchLocations]; arguments []; default message [searchLocations]]; default message [Property 'searchLocations' threw exception; nested exception is java.lang.NullPointerException]
Field error in object 'spring.cloud.config.server.native' on field 'searchLocations': rejected value [null,null]; codes [methodInvocation.spring.cloud.config.server.native.searchLocations,methodInvocation.searchLocations,methodInvocation.[Ljava.lang.String;,methodInvocation]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [spring.cloud.config.server.native.searchLocations,searchLocations]; arguments []; default message [searchLocations]]; default message [Property 'searchLocations' threw exception; nested exception is java.lang.NullPointerException]
2018-09-03 11:43:17.416 |-INFO [localhost-startStop-1] org.springframework.jmx.export.annotation.AnnotationMBeanExporter [449] -| Unregistering JMX-exposed beans on shutdown
2018-09-03 11:43:17.416 |-INFO [localhost-startStop-1] org.springframework.boot.autoconfigure.logging.AutoConfigurationReportLoggingInitializer [101] -|
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-09-03 11:43:17.416 |-ERROR [localhost-startStop-1] org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter [42] -|
***************************
APPLICATION FAILED TO START
***************************
Description:
Binding to target org.springframework.cloud.config.server.environment.NativeEnvironmentRepository@5ab0b1ef failed:
Property: spring.cloud.config.server.native.searchLocations
Value: null
Reason: Property 'searchLocations' threw exception; nested exception is java.lang.NullPointerException
Property: spring.cloud.config.server.native.searchLocations
Value: null,null
Reason: Property 'searchLocations' threw exception; nested exception is java.lang.NullPointerException
Action:
Update your application's configuration
求大神帮忙推测可能的原因,我是按照官方文档进行搭建的,基本没有任何差异的地方,还是不行。求解。。。。。