spring-cloud-config:spring-cloud-config Maven配置错误
Posted
技术标签:
【中文标题】spring-cloud-config:spring-cloud-config Maven配置错误【英文标题】:spring-cloud-config: spring-cloud-config maven config error 【发布时间】:2018-05-30 14:08:35 【问题描述】:我尝试写一个spring cloud config server example.My maven的pom config
<parent>
<groupId>cn.bcolor</groupId>
<artifactId>bcolor-parent-pom</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>cn.bcolor</groupId>
<artifactId>bcolor-config-center</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
</dependencies>
在bcolor-parent-pom
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.5.9.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Edgware.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
当我运行程序时,异常如下
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$$29caa1fa]: 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.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cloud.config.server.config.DefaultRepositoryConfiguration': Unsatisfied dependency expressed through field 'transportConfigCallback'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'propertiesBasedSshTransportCallback' defined in class path resource [org/springframework/cloud/config/server/config/TransportConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.eclipse.jgit.api.TransportConfigCallback]: Factory method 'propertiesBasedSshTransportCallback' threw exception; nested exception is java.lang.AbstractMethodError: org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.forExecutables()Ljavax/validation/executable/ExecutableValidator;
我是按照官网的例子配置的。除了这个pom文件
请帮帮我,谢谢!
【问题讨论】:
听起来你有混合版本的 spring 依赖项 用 mvn -X dependency:tree 可以看到 【参考方案1】:你的 pom 是否有这样的 spring.verion 属性:
<properties>
<spring.version>4.3.8.RELEASE</spring.version>
</properties>
如果在运行 'mvn spring-boot:run' 命令时同时使用 spring.verion 属性、spring-boot-maven-plugin 和 Spring Config,将会出现错误。
[错误] 无法执行目标 org.springframework.boot:spring-boot-maven-plugin:1.5.8.RELEASE:run (default-cli) on project without-parent: 运行时发生异常。 null:InvocationTargetException:在类路径资源[org/springframework/cloud/config/server/config/TransportConfiguration.class]中定义名称为“propertiesBasedSshTransportCallback”的bean创建错误:通过工厂方法进行的bean实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.eclipse.jgit.api.TransportConfigCallback]:工厂方法“propertiesBasedSshTransportCallback”抛出异常;嵌套异常是 java.lang.AbstractMethodError: org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.forExecutables()Ljavax/validation/executable/ExecutableValidator; -> [帮助 1]
【讨论】:
以上是关于spring-cloud-config:spring-cloud-config Maven配置错误的主要内容,如果未能解决你的问题,请参考以下文章
问题 spring-cloud-config 和 spring-cloud-bus
为啥 spring-cloud-config 示例测试需要旋转配置服务器?
java学习---Spring Cloud Config分布式配置中心