cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache CXF Documentation > JAX-RS Maven Plugins
Date Fri, 06 Jan 2012 11:09:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CXF20DOC&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CXF20DOC/JAX-RS+Maven+Plugins">JAX-RS
Maven Plugins</a></h2>
    <h4>Page  <b>added</b> by             <a href="https://cwiki.apache.org/confluence/display/~sergey_beryozkin">Sergey
Beryozkin</a>
    </h4>
         <br/>
    <div class="notificationGreySide">
         <p><span style="font-size:2em;font-weight:bold"> JAX-RS: Maven Plugins
</span></p>


<div>
<ul>
    <li><a href='#JAX-RSMavenPlugins-Introduction'>Introduction</a></li>
    <li><a href='#JAX-RSMavenPlugins-Archetypes'>Archetypes</a></li>
</ul></div>

<h1><a name="JAX-RSMavenPlugins-Introduction"></a>Introduction</h1>

<p>A <a href="http://cxf.apache.org/docs/jaxrs-services-description.html#JAXRSServicesDescription-wadl2javaMavenplugin"
class="external-link" rel="nofollow">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><a name="JAX-RSMavenPlugins-Archetypes"></a>Archetypes</h1>

<p><a href="http://maven.apache.org/archetype/maven-archetype-plugin/" class="external-link"
rel="nofollow">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" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
~/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
├── pom.xml
└── src
    ├── main
    │   ├── java
    │   │   └── org
    │   │       └── examples
    │   │           └── rest
    │   │               ├── HelloWorld.java
    │   │               └── JsonBean.java
    │   └── webapp
    │       └── WEB-INF
    │           ├── beans.xml
    │           └── web.xml
    └── test
        └── java
            └── org
                └── examples
                    └── rest
                        └── 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 id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>
       <a href="https://cwiki.apache.org/confluence/display/CXF20DOC/JAX-RS+Maven+Plugins">View
Online</a>
              |
       <a href="https://cwiki.apache.org/confluence/display/CXF20DOC/JAX-RS+Maven+Plugins?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
           </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message