JAX-RS_ in intellij
Create project with java enterprise. Project template as web application
next,#
In specification selecti RESTful web services(JAX-RS).
Create the project:
Add the maven framework if needed.
Add this dependencies:
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>${jersey.version}</version>
</dependency>
Add this properties:
<jersey.version>2.29.1</jersey.version>
In webapp/WEB-INF/web.xml, add
<servlet>
<servlet-name>API Root</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.example</param-value> <!-- TODO: replace this with your own groupId -->
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>API Root</servlet-name>
<url-pattern>/api/*</url-pattern> <!-- TODO: replace this with your own prefered path -->
</servlet-mapping>
param-value as your package name.
http://localhost:8080/RESTFul_Messenger_war_exploded/api/hello-world
Good to go...........
Comments
Post a Comment