Java CXF 不带弹簧
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/689902/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CXF without Spring
提问by Maurice Perry
Is it possible to use CXF with Tomcat and without Spring? If so, how?
是否可以在没有 Spring 的情况下将 CXF 与 Tomcat 一起使用?如果是这样,如何?
采纳答案by kgiannakakis
I suppose you mean to create a Web Service with CFX that it would run in Tomcat? This is totally possible and Spring is optional. You don't have to use it, if you don't want to.
我想您的意思是使用 CFX 创建一个可以在 Tomcat 中运行的 Web 服务?这是完全可能的,Spring 是可选的。如果您不想,则不必使用它。
回答by H Marcelo Morales
CXF is meant to be used with spring. It is strange you want to use it without it.
CXF 旨在与弹簧一起使用。奇怪的是你想在没有它的情况下使用它。
You could try NoSpringServletServer and use the ServerFactoryBean or JaxWS API.
您可以尝试 NoSpringServletServer 并使用 ServerFactoryBean 或 JaxWS API。
Here is the code for the NoSpringServletServer.
这是NoSpringServletServer的代码。
But you will stillneed spring as a dependency. The basic JaxWS can be done without spring. But for almost anything else you will need at the very least spring-core.jar
但是您仍然需要 spring 作为依赖项。基本的 JaxWS 可以不用 spring。但是对于几乎任何其他事情,您至少需要 spring-core.jar
回答by H Marcelo Morales
I dont think it is possible to use CXF completely independent of spring in Tomcat.
我认为在 Tomcat 中完全独立于 spring 使用 CXF 是不可能的。
Reason is that when I do a Maven dependency tree list (mvn dependency:tree) for a bare minimum CXF webservice, the following is listed (which shows that it needs Spring)
原因是当我为一个最低限度的 CXF webservice 做一个 Maven 依赖树列表(mvn dependency:tree)时,列出了以下内容(这表明它需要 Spring)
+- org.apache.cxf:cxf-rt-core:jar:2.2.2:compile
[INFO] | | +- com.sun.xml.bind:jaxb-impl:jar:2.1.9:compile
[INFO] | | +- org.springframework:spring-core:jar:2.5.5:compile
[INFO] | | +- org.apache.geronimo.specs:geronimo-javamail_1.4_spec:jar:1.6:compile
org.apache.cxf:cxf-rt-transports-http:jar:2.2.2:compile
[INFO] \- org.springframework:spring-web:jar:2.5.5:compile
[INFO] +- commons-logging:commons-logging:jar:1.1.1:compile
回答by H Marcelo Morales
You can configure CXF programmatically without Spring. See the code examples here. Putting the web application context path together with the end point extension--Greeter in the code example--will display a summary page in the browser with a link to the WSDL.
您可以在没有 Spring 的情况下以编程方式配置 CXF。请参阅此处的代码示例。将 Web 应用程序上下文路径与端点扩展(代码示例中的 Greeter)放在一起,将在浏览器中显示一个带有 WSDL 链接的摘要页面。
No Spring necessary, giving CXF a very small footprint. I found the only jars necessary to be (for CXF 2.2.1):
不需要 Spring,使 CXF 占用空间很小。我发现唯一需要的罐子(对于 CXF 2.2.1):
- XmlSchema-1.4.5.jar
- cxf-2.2.3.jar
- wsdl4j-1.6.2.jar
- XmlSchema-1.4.5.jar
- cxf-2.2.3.jar
- wsdl4j-1.6.2.jar
I believe neethi-2.0.4.jar may also be necessary for some configurations, but I haven't needed it.
我相信 neethi-2.0.4.jar 对于某些配置也可能是必要的,但我不需要它。
Have fun!
玩得开心!