我使用undertow + resteasy + ajckson开发了REST服务,当我使用IDEA运行时,一切正常,但是当我创建“脂肪瓶” gradle这个或Maven我得到的查询过程中出现错误:org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure:无法找到类型为
org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure:无法 在 org.jboss.resteasy找到MessageBodyWriter为 类型的响应对象。 core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:67) at org.jboss.resteasy.core.SynchronousDispatcher.writeResponse(Synchro nousDispatcher.java:448) 在 org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:397) 在 org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:200) 在 org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220) 在 org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56) 在 org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
我可以用gradle build
创建没有错误的jar,并在IDEA中调试我的服务。
我gradle这个文件:
apply plugin: 'application'
apply plugin: 'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8
mainClassName = 'example.json.RestServer'
jar {
manifest {
attributes 'Implementation-Title': 'Rest-server',
'Implementation-Version': '0.1',
'Main-Class': 'example.json.RestServer'
}
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
}
repositories {
jcenter()
}
dependencies {
compile 'io.undertow:undertow-core:1.4.0.Final'
compile 'io.undertow:undertow-servlet:1.4.0.Final'
compile 'org.jboss.resteasy:jaxrs-api:3.0.12.Final'
compile 'org.jboss.resteasy:resteasy-undertow:3.0.12.Final'
compile 'org.jboss.resteasy:resteasy-jackson-provider:3.0.12.Final'
testCompile 'junit:junit:4.12'
}
我来源:
@Path("calculator")
public class Calculator {
@GET
@Path("squareRoot")
@Produces(MediaType.APPLICATION_JSON)
public Response squareRoot(@QueryParam("input") double input){
Result result = new Result("Square Root");
result.setInput(input);
result.setOutput(Math.sqrt(result.getInput()));
return Response.status(200).entity(result).build();
}
一切都OK withmy代码,我有错误与建设的jar文件,但我无法找到在哪里 – mystdeim