java - How to create the CXFServlet? -
prior cxf-3.1.0
1 use new org.apache.cxf.transport.servlet.cxfservlet()
instantiate servlet, or via web.xml
configuration:
<servlet> <servlet-name>cxfservlet</servlet-name> <display-name>cxf servlet</display-name> <servlet-class> org.apache.cxf.transport.servlet.cxfservlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet>
but when upgrade 3.1.0, class cannot found anymore.
how the servlet created cxf?
i have simple spring boot application works correctly cxfservlet - here extract pom.xml:
<properties> <project.build.sourceencoding>utf-8</project.build.sourceencoding> <start-class>demo.demoapplication</start-class> <java.version>1.7</java.version> <cxf.version>3.1.0</cxf.version> </properties> <dependency> <groupid>org.apache.cxf</groupid> <artifactid>cxf-rt-frontend-jaxws</artifactid> <version>${cxf.version}</version> </dependency> <dependency> <groupid>org.apache.cxf</groupid> <artifactid>cxf-rt-transports-http</artifactid> <version>${cxf.version}</version> </dependency>
and create new servlet like
@springbootapplication @importresource({"classpath:/cxf-servlet.xml" }) public class demoapplication { public static void main(string[] args) { springapplication.run(demoapplication.class, args); } @bean public servletregistrationbean cxfservlet() { org.apache.cxf.transport.servlet.cxfservlet cxfservlet = new org.apache.cxf.transport.servlet.cxfservlet(); servletregistrationbean servletdef = new servletregistrationbean(cxfservlet, "/cxf/*"); servletdef.setloadonstartup(1); return servletdef; } }
Comments
Post a Comment