<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>jaxrs</artifactId>
</dependency>
JAX-RS
JAX-RS is a standard JavaEE API for defining web services. It can be used to replace Servlet
-based applications where resources are well-defined, such as in RESTful architectures.
WildFly Swarm supports JAX-RS with both .war
and .jar
deployments.
Configuration
To bring JAX-RS functionality to your application, you need the following dependency:
Usage
The jaxrs
fraction brings the JAX-RS APIs to your application through a transitive dependency. It also provides a JAXRSArchive
archive type for easily creating JAX-RS-based deployments if you provide your own main(…)
method.
JAXRSArchive deployment = ShrinkWrap.create( JAXRSArchive.class );
deployment.addResource( SomeResource.class );
Additionally, the JAXRSArchive
can provide a default Application
with the @ApplicationPath
annotation if you do not provide one when creating the deployment. If you do provide an Application
it will take precedence.
If you are building a .war
-based application, you must provide the Application
implementation with the appropriate @ApplicationPath
annotation.
Using JAX-RS with CDI
By default, JAX-RS does not provide CDI support. To bring CDI support to your application, an additional dependency is required:
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>jaxrs-cdi</artifactId>
</dependency>
In reality, this dependency will transitively bring in the core jaxrs
dependency.
Using JAX-RS with multipart forms
To use JAX-RS with multipart forms (to support file uploads, for instance), another dependency is required:
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>jaxrs-multipart</artifact>
</dependency>