blob: 06c1e02c8eaf361f198addb1d76643d91aa0f018 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
<head>
<link type="text/css" rel="stylesheet" href="/resources/site.css">
<script src='/resources/space.js'></script>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<meta name="keywords" content="business integration, EAI, SOA, Service Oriented Architecture, web services, SOAP, JBI, JMS, WSDL, XML, EDI, Electronic Data Interchange, standards support, integration standards, application integration, middleware, software, solutions, services, CXF, open source">
<meta name="description" content="Apache CXF, Services Framework - JAX-RS Maven Plugins">
<link type="text/css" rel="stylesheet" href="/resources/highlighter/styles/shCoreCXF.css">
<link type="text/css" rel="stylesheet" href="/resources/highlighter/styles/shThemeCXF.css">
<script src='/resources/highlighter/scripts/shCore.js'></script>
<script src='/resources/highlighter/scripts/shBrushXml.js'></script>
<script src='/resources/highlighter/scripts/shBrushJava.js'></script>
<script>
SyntaxHighlighter.defaults['toolbar'] = false;
SyntaxHighlighter.all();
</script>
<title>
Apache CXF -- JAX-RS Maven Plugins
</title>
</head>
<body onload="init()">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td id="cell-0-0" colspan="2">&nbsp;</td>
<td id="cell-0-1">&nbsp;</td>
<td id="cell-0-2" colspan="2">&nbsp;</td>
</tr>
<tr>
<td id="cell-1-0">&nbsp;</td>
<td id="cell-1-1">&nbsp;</td>
<td id="cell-1-2">
<!-- Banner -->
<div class="banner" id="banner"><div><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td align="left" colspan="1" nowrap>
<a shape="rect" href="http://cxf.apache.org/" title="Apache CXF"><span style="font-weight: bold; font-size: 170%; color: white">Apache CXF</span></a>
</td><td align="right" colspan="1" nowrap>
<a shape="rect" href="http://www.apache.org/" title="The Apache Sofware Foundation"><img border="0" alt="ASF Logo" src="http://cxf.apache.org/images/asf-logo.png"></a>
</td></tr></table></div></div>
<!-- Banner -->
<div id="top-menu">
<table border="0" cellpadding="1" cellspacing="0" width="100%">
<tr>
<td>
<div align="left">
<!-- Breadcrumbs -->
<a href="index.html">Index</a>&nbsp;&gt;&nbsp;<a href="restful-services.html">RESTful Services</a>&nbsp;&gt;&nbsp;<a href="jax-rs.html">JAX-RS</a>&nbsp;&gt;&nbsp;<a href="jax-rs-maven-plugins.html">JAX-RS Maven Plugins</a>
<!-- Breadcrumbs -->
</div>
</td>
<td>
<div align="right">
<!-- Quicklinks -->
<div id="quicklinks"><p><a shape="rect" href="http://cxf.apache.org/download.html">Download</a> | <a shape="rect" href="http://cxf.apache.org/docs/index.html">Documentation</a></p></div>
<!-- Quicklinks -->
</div>
</td>
</tr>
</table>
</div>
</td>
<td id="cell-1-3">&nbsp;</td>
<td id="cell-1-4">&nbsp;</td>
</tr>
<tr>
<td id="cell-2-0" colspan="2">&nbsp;</td>
<td id="cell-2-1">
<table>
<tr valign="top">
<td height="100%">
<div id="wrapper-menu-page-right">
<div id="wrapper-menu-page-top">
<div id="wrapper-menu-page-bottom">
<div id="menu-page">
<!-- NavigationBar -->
<div id="navigation"><ul class="alternate"><li><a shape="rect" href="overview.html">Overview</a></li><li><a shape="rect" href="how-tos.html">How-Tos</a></li><li><a shape="rect" href="frontends.html">Frontends</a></li><li><a shape="rect" href="databindings.html">DataBindings</a></li><li><a shape="rect" href="transports.html">Transports</a></li><li><a shape="rect" href="configuration.html">Configuration</a></li><li><a shape="rect" href="debugging-and-logging.html">Debugging and Logging</a></li><li><a shape="rect" href="tools.html">Tools</a></li><li><a shape="rect" href="restful-services.html">RESTful Services</a></li><li><a shape="rect" href="wsdl-bindings.html">WSDL Bindings</a></li><li><a shape="rect" href="service-routing.html">Service Routing</a></li><li><a shape="rect" href="dynamic-languages.html">Dynamic Languages</a></li><li><a shape="rect" href="ws-support.html">WS-* Support</a></li><li><a shape="rect" href="advanced-integration.html">Advanced Integration</a></li><li><a shape="rect" href="deployment.html">Deployment</a></li><li><a shape="rect" href="schemas-and-namespaces.html">Use of Schemas and Namespaces</a></li></ul><hr><ul class="alternate"><li><p>Search</p></li></ul><form enctype="application/x-www-form-urlencoded" method="get" id="cse-search-box" action="http://www.google.com/cse">
<div>
<input type="hidden" name="cx" value="002890367768291051730:o99qiwa09y4">
<input type="hidden" name="ie" value="UTF-8">
<input type="text" name="q" size="21">
<input type="submit" name="sa" value="Search">
</div>
</form>
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&amp;lang=en"></script><hr><ul class="alternate"><li><a shape="rect" href="http://cxf.apache.org/javadoc/latest/">API 3.2.x (Javadoc)</a></li><li><a shape="rect" href="http://cxf.apache.org/javadoc/latest-3.1.x/">API 3.1.x (Javadoc)</a></li><li><a shape="rect" href="http://cxf.apache.org/">CXF Website</a></li></ul><p>&#160;</p><p><a shape="rect" class="external-link" href="http://www.apache.org/events/current-event.html"><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image confluence-external-resource" src="http://www.apache.org/events/current-event-125x125.png" data-image-src="http://www.apache.org/events/current-event-125x125.png"></span></a></p></div>
<!-- NavigationBar -->
</div>
</div>
</div>
</div>
</td>
<td height="100%">
<!-- Content -->
<div class="wiki-content">
<div id="ConfluenceContent"><p></p><p></p><p></p><p></p><p><span style="font-size:2em;font-weight:bold"> JAX-RS: Maven Plugins </span>
</p><p></p><p></p><p></p><p></p><p></p>
<style type="text/css">/*<![CDATA[*/
div.rbtoc1636141717648 {padding: 0px;}
div.rbtoc1636141717648 ul {list-style: disc;margin-left: 0px;}
div.rbtoc1636141717648 li {margin-left: 0px;padding-left: 0px;}
/*]]>*/</style><div class="toc-macro rbtoc1636141717648">
<ul class="toc-indentation"><li><a shape="rect" href="#JAXRSMavenPlugins-Introduction">Introduction</a></li><li><a shape="rect" href="#JAXRSMavenPlugins-Archetypes">Archetypes</a></li></ul>
</div>
<h1 id="JAXRSMavenPlugins-Introduction">Introduction</h1>
<p>A <a shape="rect" href="http://cxf.apache.org/docs/jaxrs-services-description.html#JAXRSServicesDescription-wadl2javaMavenplugin">wadl2java</a> Maven plugin for generating the Java code from WADL documents and a new Maven archetype for speeding up the creation of Spring-based CXF JAX-RS web applications are currently available. </p>
<h1 id="JAXRSMavenPlugins-Archetypes">Archetypes</h1>
<p><a shape="rect" class="external-link" href="http://maven.apache.org/archetype/maven-archetype-plugin/">Maven archetypes</a> can help with creating the boilerplate code which can be used to build a working application fast.</p>
<p>CXF 2.5.1 introduces an org.apache.cxf.archetype:cxf-jaxrs-service archetype plugin for creating and testing a simple Spring-based JAX-RS web application.</p>
<p>Here is how you can use it from the command line.</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default">
~/work/archetypes$
mvn archetype:generate -Dfilter=org.apache.cxf.archetype:
[INFO] Scanning for projects...
[INFO]
......
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
1: remote -&gt; org.apache.cxf.archetype:cxf-jaxrs-service (Simple CXF JAX-RS webapp service using Spring configuration)
2: remote -&gt; org.apache.cxf.archetype:cxf-jaxws-javafirst (Creates a project for developing a Web service starting from Java code)
Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : 1
Choose version:
1: 2.5.1
2: 2.5.2-SNAPSHOT
Choose a number: 2: 1
Downloading: http://repo1.maven.org/maven2/org/apache/cxf/archetype/cxf-jaxrs-service/2.5.1/cxf-jaxrs-service-2.5.1.jar
Downloaded: http://repo1.maven.org/maven2/org/apache/cxf/archetype/cxf-jaxrs-service/2.5.1/cxf-jaxrs-service-2.5.1.jar (10 KB at 15.2 KB/sec)
......
Define value for property 'groupId': : org.examples.rest
Define value for property 'artifactId': : simple
Define value for property 'version': 1.0-SNAPSHOT: :
Define value for property 'package': org.examples.rest: :
Confirm properties configuration:
groupId: org.examples.rest
artifactId: simple
version: 1.0-SNAPSHOT
package: org.examples.rest
Y: : Y
[INFO] project created from Archetype in dir: ~/work/archetypes/simple
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
~/work/archetypes$ tree simple
simple
&#9500;&#9472;&#9472; pom.xml
&#9492;&#9472;&#9472; src
&#9500;&#9472;&#9472; main
&#9474;&#160;&#160; &#9500;&#9472;&#9472; java
&#9474;&#160;&#160; &#9474;&#160;&#160; &#9492;&#9472;&#9472; org
&#9474;&#160;&#160; &#9474;&#160;&#160; &#9492;&#9472;&#9472; examples
&#9474;&#160;&#160; &#9474;&#160;&#160; &#9492;&#9472;&#9472; rest
&#9474;&#160;&#160; &#9474;&#160;&#160; &#9500;&#9472;&#9472; HelloWorld.java
&#9474;&#160;&#160; &#9474;&#160;&#160; &#9492;&#9472;&#9472; JsonBean.java
&#9474;&#160;&#160; &#9492;&#9472;&#9472; webapp
&#9474;&#160;&#160; &#9492;&#9472;&#9472; WEB-INF
&#9474;&#160;&#160; &#9500;&#9472;&#9472; beans.xml
&#9474;&#160;&#160; &#9492;&#9472;&#9472; web.xml
&#9492;&#9472;&#9472; test
&#9492;&#9472;&#9472; java
&#9492;&#9472;&#9472; org
&#9492;&#9472;&#9472; examples
&#9492;&#9472;&#9472; rest
&#9492;&#9472;&#9472; HelloWorldIT.java
~/work/archetypes$ cd simple
~/work/archetypes/simple$ mvn install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Simple CXF JAX-RS webapp service using spring configuration 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/org/apache/cxf/cxf-rt-frontend-jaxrs/2.5.1/cxf-rt-frontend-jaxrs-2.5.1.pom
......
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ simple ---
[INFO] Compiling 2 source files to ~/work/archetypes/simple/target/classes
[INFO]
......
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ simple ---
......
[INFO] Building war: ~/work/archetypes/simple/target/simple-1.0-SNAPSHOT.war
[INFO]
[INFO] &lt;&lt;&lt; tomcat-maven-plugin:1.1:run-war (start-tomcat) @ simple &lt;&lt;&lt;
[INFO]
[INFO] --- tomcat-maven-plugin:1.1:run-war (start-tomcat) @ simple ---
[INFO] Running war on http://localhost:47586/jaxrs-service
......
INFO: Starting tomcat server
06-Jan-2012 12:47:53 org.apache.catalina.core.StandardEngine start
......
INFO: Starting Coyote HTTP/1.1 on http-47586
[INFO]
......
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.examples.rest.HelloWorldIT
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.823 sec
Results :
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
......
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ simple ---
[INFO] Installing ~/work/archetypes/simple/target/simple-1.0-SNAPSHOT.war to ~/.m2/repository/org/examples/rest/simple/1.0-SNAPSHOT/simple-1.0-SNAPSHOT.war
[INFO] Installing ~/work/archetypes/simple/pom.xml to ~/.m2/repository/org/examples/rest/simple/1.0-SNAPSHOT/simple-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
~/work/archetypes/simple$
</pre>
</div></div>
<p>Note that an "org.apache.cxf.archetype:" filter is used to restrict a number of available archetypes and then a jaxrs archetype is selected. After the sample project has been created it is built and the integration tests are run.</p>
<p>Integration with Eclipse should also be possible.</p></div>
</div>
<!-- Content -->
</td>
</tr>
</table>
</td>
<td id="cell-2-2" colspan="2">&nbsp;</td>
</tr>
<tr>
<td id="cell-3-0">&nbsp;</td>
<td id="cell-3-1">&nbsp;</td>
<td id="cell-3-2">
<div id="footer">
<!-- Footer -->
<div id="site-footer">
<a href="http://cxf.apache.org/privacy-policy.html">Privacy Policy</a> -
(<a href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=27835077">edit page</a>)
(<a href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=27835077&amp;showComments=true&amp;showCommentArea=true#addcomment">add comment</a>)<br>
Apache CXF, CXF, Apache, the Apache feather logo are trademarks of The Apache Software Foundation.<br>
All other marks mentioned may be trademarks or registered trademarks of their respective owners.
</div>
<!-- Footer -->
</div>
</td>
<td id="cell-3-3">&nbsp;</td>
<td id="cell-3-4">&nbsp;</td>
</tr>
<tr>
<td id="cell-4-0" colspan="2">&nbsp;</td>
<td id="cell-4-1">&nbsp;</td>
<td id="cell-4-2" colspan="2">&nbsp;</td>
</tr>
</table>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-4458903-1");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>