问题描述
我已经在客户端上升级到ReastEasy 4,但是根据配置报告了一些错误。
如果我仅使用resteasy-core-spi
和resteasy-client-api
,我会得到
Exception in thread "main" java.lang.RuntimeException: java.lang.classNotFoundException: org.glassfish.jersey.client.JerseyClientBuilder
如果我添加resteasy-client
,我会得到
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
添加resteasy-core
无济于事。 documentation仅指定resteasy-client
和resteasy-core
,但上面仍然显示错误。
此外,我在客户端中使用Jackson,因此我指定了resteasy-jackson2-provider
。
所有版本均为4.5.8.Final。
以前使用resteasy-jaxrs
的版本3可以正常工作,但是显然是removed from 4。
我看过javax.ws.rs.ProcessingException: could not find writer for content-type application/json和Why is there no maven resteasy-jaxrs package for version 4.2.0?,但那里没有解决方案。
第4版客户端需要哪些依赖项?
更新: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'
}
呼叫站点:
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);
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)