unmigrated-inline-wiki-markup |
---|
{span:style=font-size:2em;font-weight:bold} JAX-RS: Maven Plugins {span} |
...
Table of Contents |
---|
Introduction
A wadl2java 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.
Archetypes
Maven archetypes can help with creating the boilerplate code which can be used to build a working application fast.
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.
...
Here
...
is
...
how
...
you
...
can
...
use
...
it
...
from
...
the
...
command
...
line.
Code Block | ||||
---|---|---|---|---|
| ||||
{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 -> org.apache.cxf.archetype:cxf-jaxrs-service (Simple CXF JAX-RS webapp service using Spring configuration) 2: remote -> 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] <<< tomcat-maven-plugin:1.1:run-war (start-tomcat) @ simple <<< [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$ {code} Note that an |
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.
...
Integration
...
with
...
Eclipse
...
should
...
also
...
be
...
possible.