问题
I've upgraded to ReastEasy 4 on my client, but there are several errors reported depending on the configuration.
If I use only resteasy-core-spi
and resteasy-client-api
, I get
Exception in thread "main" java.lang.RuntimeException: java.lang.ClassNotFoundException: org.glassfish.jersey.client.JerseyClientBuilder
If I add resteasy-client
, I get instead
javax.ws.rs.ProcessingException: RESTEASY004655: Unable to invoke request:
javax.ws.rs.ProcessingException: RESTEASY003215: could not find writer for content-type application/json type: java.lang.String
Adding resteasy-core
does not help. The documentation specifies only resteasy-client
and resteasy-core
, but I still get the error above.
Additionally, I use Jackson in my client, so I specified resteasy-jackson2-provider
.
All versions are 4.5.8.Final.
Things used to work fine with version 3 using resteasy-jaxrs
, but it was removed from 4 apparently.
I've looked at javax.ws.rs.ProcessingException: could not find writer for content-type application/json and Why is there no maven resteasy-jaxrs package for version 4.2.0?, but there is no solution there.
What are the needed dependencies for a version 4 client?
Update: build.gradle
repositories {
jcenter()
mavenCentral()
}
apply plugin: 'java'
apply plugin: 'eclipse'
sourceCompatibility = 14
targetCompatibility = 14
ext.resteasyVersion = "4.5.8.Final";
dependencies {
// compile "org.jboss.resteasy:resteasy-core:$resteasyVersion"
// compile "org.jboss.resteasy:resteasy-core-spi:$resteasyVersion"
// compile "org.jboss.resteasy:resteasy-client-api:$resteasyVersion"
compile "org.jboss.resteasy:resteasy-client:$resteasyVersion"
compile "org.jboss.resteasy:resteasy-jackson2-provider:$resteasyVersion"
compileOnly "org.projectlombok:lombok:1.18.12"
annotationProcessor 'org.projectlombok:lombok:1.18.12'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.5.2'
testCompile 'org.junit.platform:junit-platform-launcher:1.5.2'
}
Call site:
String stateString = MAPPER.writeValueAsString(state); // Mapper is ObjectMapper
Entity entity = Entity.entity(clientStateString, MediaType.TEXT_PLAIN); // or other media type
Response response = target.request().put(entity);
来源:https://stackoverflow.com/questions/64115996/which-reasteasy-4-client-dependencies-are-needed