cat集成项目所遇到的一些坑

第一个问题:(jar包依赖冲突)

启动报错,直接贴log

zhengxin-third-shanghai-cis [2017-08-21 14:17:49] 56231 WARN [main]  - AnnotationConfigEmbeddedWebApplicationContext:487: Exception encountered during context initialization - cancelling refresh attempt
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474)
  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)
  at com.ctc..framework.Server.<init>(Server.java:49)
  at com.ctc..framework.Server.<init>(Server.java:23)
  at com.ctc..third.Main.main(Main.java:23)
Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
  at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:98)
  at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:75)
  at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:378)
  at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:155)
  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:157)
  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
  ... 9 more
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter':
Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException:
Could not autowire field: private org.springframework.boot.autoconfigure.web.HttpMessageConverters
org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.messageConverters;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration':
Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException:
Could not autowire field: private final java.util.List org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration.converters;
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'mappingJackson2HttpMessageConverter' defined in class path resource
[org/springframework/boot/autoconfigure/web/JacksonHttpMessageConvertersConfiguration$MappingJackson2HttpMessageConverterConfiguration.class]:
Unsatisfied dependency expressed through constructor argument with index 0 of type [com.fasterxml.jackson.databind.ObjectMapper]:
: Error creating bean with name 'jacksonObjectMapper' defined in class path resource
[org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration$JacksonObjectMapperConfiguration.class]:
Unsatisfied dependency expressed through constructor argument with index 0 of type
[org.springframework.http.converter.json.Jackson2ObjectMapperBuilder]:
: Error creating bean with name 'jacksonObjectMapperBuilder' defined in class path resource
[org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration$JacksonObjectMapperBuilderConfiguration.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.springframework.http.converter.json.Jackson2ObjectMapperBuilder]:
Factory method 'jacksonObjectMapperBuilder' threw exception; nested exception is java.lang.NoSuchMethodError:
org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.applicationContext(Lorg/springframework/context/ApplicationContext;)
Lorg/springframework/http/converter/json/Jackson2ObjectMapperBuilder;; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'jacksonObjectMapperBuilder' defined in class path resource
[org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration$JacksonObjectMapperBuilderConfiguration.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.springframework.http.converter.json.Jackson2ObjectMapperBuilder]:
Factory method 'jacksonObjectMapperBuilder' threw exception; nested exception is java.lang.NoSuchMethodError:
org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.applicationContext(Lorg/springframework/context/ApplicationContext;)
Lorg/springframework/http/converter/json/Jackson2ObjectMapperBuilder;;
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'jacksonObjectMapper' defined in class path resource
[org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration$JacksonObjectMapperConfiguration.class]:
Unsatisfied dependency expressed through constructor argument with index 0 of type
[org.springframework.http.converter.json.Jackson2ObjectMapperBuilder]:
: Error creating bean with name 'jacksonObjectMapperBuilder' defined in class path resource
[org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration$JacksonObjectMapperBuilderConfiguration.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.springframework.http.converter.json.Jackson2ObjectMapperBuilder]:
Factory method 'jacksonObjectMapperBuilder' threw exception; nested exception is java.lang.NoSuchMethodError:
org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.applicationContext(Lorg/springframework/context/ApplicationContext;)
Lorg/springframework/http/converter/json/Jackson2ObjectMapperBuilder;;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'jacksonObjectMapperBuilder' defined in class path resource
[org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration$JacksonObjectMapperBuilderConfiguration.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.springframework.http.converter.json.Jackson2ObjectMapperBuilder]:
Factory method 'jacksonObjectMapperBuilder' threw exception; nested exception is java.lang.NoSuchMethodError:
org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.applicationContext(Lorg/springframework/context/ApplicationContext;)
Lorg/springframework/http/converter/json/Jackson2ObjectMapperBuilder;

 

最重要的是

 Error creating bean with name 'jacksonObjectMapperBuilder' defined in class path resource 

这个错

原因:pom.xml 中的jar包依赖冲突了;

解决办法:


jackson-databind

stackoverflow上面说的很清楚,是这个jar包冲突了。

右键pom.xml,打开项目中的maven,show dependencies,搜索jackson-databind,右键excloud就ok了;

 

 

 

 

 

第二个问题:cat集成的时候,pom.xml 添加以下东西

<!-- Cat 集成 -->
<dependency>
<groupId>com.madai.rong</groupId>
<artifactId>rong-cat</artifactId>
<version>1.0.4-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.dianping.cat</groupId>
<artifactId>cat-client</artifactId>
<version>1.4.0-RELEASE</version>
</dependency>
<!-- Cat 集成 END -->

 

本地需要添加客户端配置文件。

在/data/appdatas/cat目录下添加client.xml

内容如下:

<?xml version="1.0" encoding="utf-8"?>

          <config mode="client" xmlns:xsi="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="config.xsd" enabled="true">
          <servers>
                 <server ip="*.*.*.*" port="2280" http-port="10083" />
          </servers>
</config>

注意,我这里犯了一个错,就是编写xml的时候,我习惯性的空了一行,打了个回车,于是解析xml的时候报错了,切记不能回车。

 

 

 

 

 

over...

posted @ 2017-08-21 18:11  ctgu_czy  阅读(585)  评论(0编辑  收藏