在web工程中,写main方法,运行ok。
发布到tomcat中后,报错。
javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder
Caused by:java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:286)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:218)
几经折腾,最后发现原来需要添加一个jaxrs的依赖。无论是glassfish项目当中提供的引用实现,或者apache cxf应该也可以。附上对于glassfish项目对jarxs参考实现的maven项目依赖。
<dependency>
<groupId>org.glassfish.jersey.bundles</groupId>
<artifactId>jaxrs-ri</artifactId>
<version>2.4</version>
</dependency>
注:JAXRS == Java API for RESTful Web Services