我想使用 CXF 创建一个休息客户端。以下代码抛出异常
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(Blogger.class);
sf.getInInterceptors().add(new LoggingInInterceptor());
sf.getOutInterceptors().add(new LoggingOutInterceptor());
sf.setAddress("http://myservice");
Map<Object, Object> mappings = new HashMap<Object, Object>();
mappings.put("xml", "application/xml");
mappings.put("json", "application/json");
sf.setExtensionMappings(mappings);
sf.create();
我得到的例外是
Exception in thread "main" java.lang.NoClassDefFoundError: javax/ws/rs/WebApplicationException
at com.test.LoggingTest.main(LoggingTest.java:26)
Caused by: java.lang.ClassNotFoundException: javax.ws.rs.WebApplicationException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 1 more