Gradle "Failed to resolve all dependencies for config" in Jersey / JAX-RS project

I want to add a JSON dependency to build.gradle to fix the error MessageBodyWriter not found for media type=application/json

. I found out in a previous question that it is very likely that I did not include JSON as a dependency in my build.gradle file.

I added a dependency as shown below (line 8, last compile

)

apply plugin: 'war'
apply plugin: 'jetty'

dependencies {
    compile fileTree(dir: 'lib', include: '**/*.jar')
    compile(project(":qa-common"))
    compile(project(":alm"))
    compile 'org.glassfish.jersey.media:jersey-media-json-jackson:2.3.10'
}

jettyRun {
    httpPort = 8080
    reload = 'automatic'
    scanIntervalSeconds = 2
    daemon = false
}

      

Now I am getting the error Could not resolve all dependencies for configuration'

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':qa-automation-console:compile'.
> Cannot resolve external dependency org.glassfish.jersey.media:jersey-media-json-jackson:2.3.10 because no repositories are defined.
  Required by:
  qaauto:qa-automation-console:unspecified

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 5.273 secs

      

I am checking if I have included the correct version of gradle and Jersey (in web.xml I see 2.5, but 2.5 still gives the same error). In my side jersey server code, the only jersey related package wasimport org.glassfish.jersey.server.mvc.Viewable;

Can anyone tell me what I need to add?

+3


source to share


1 answer


Define the repositories in your build.gradle file as shown below.

repositories {
      maven  {
          url "http://repo1.maven.org/maven2"
      }
}

      

Or after

repositories {
    mavenCentral()
}

      



Gradle Help Chapter 8. Dependency Management Basics 8.5. Repositories provide other examples.

You should also change your dependency to match existing versions. I linked the version page as you are requesting "version 2.3.10" which does not exist in the maven repository.

dependencies {
    compile 'org.glassfish.jersey.media:jersey-media-json-jackson:2.5'
}

      

+3


source







All Articles