0

I am using spring Boot.I created Spring boot gradle application.I got following error.

Caused by: java.lang.ClassNotFoundException: org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter

build.gradle

  buildscript {
  ext {
    springBootVersion = '1.3.2.RELEASE'
}
repositories {
    mavenCentral()
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.2.RELEASE") 
}
 }

 apply plugin: 'java'
 apply plugin: 'eclipse'
apply plugin: 'spring-boot' 

 jar {
   baseName = 'demo'
    version = '0.0.1-SNAPSHOT'
     }
 sourceCompatibility = 1.7
   targetCompatibility = 1.7

   repositories {
    mavenCentral()
    }


    dependencies {
compile('org.springframework.boot:spring-boot-starter-data-mongodb')
testCompile('org.springframework.boot:spring-boot-starter-test') 
compile group: 'org.springframework', name: 'spring-web', version:   '4.0.0.RELEASE'
compile group: 'org.codehaus.jackson', name: 'jackson-mapper-asl', version: '1.9.12'
compile group: 'org.codehaus.jackson', name: 'jackson-core-asl', version: '1.9.12'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.2.2'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.2.2'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations',  version: '2.2.2'
   }


   eclipse {
            classpath {
      containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
       containers   'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7'
  }
   }

   task wrapper(type: Wrapper) {
   gradleVersion = '2.9'
     }

Am I missing any dependency in build.gradle?

How to solve this?

user5863037
  • 79
  • 1
  • 2
  • 16
  • try this link http://stackoverflow.com/questions/27756668/spring-tool-suite-noclassdeffounderror-mappingjackson2xmlhttpmessageconverter – s7vr May 27 '16 at 12:56
  • Remove the `org.springframework`, `org.codehaus.jackson` and `com.fasterxml.jackson.core` dependencies, and replace with `org.springframework.boot:sprig-boot-starter-web` instead. – M. Deinum May 27 '16 at 13:04

1 Answers1

0

You are including two different versions of the jackson lib. For Spring 4+ use the com.fasterxml.jackson.core like you have. Remove the two org.codehaus.jackson dependencies.

dreamwagon
  • 1,219
  • 1
  • 15
  • 17