An open API service indexing awesome lists of open source software.

https://github.com/nunum/rest-server-java-skeleton

MVC Rest server in JAVA, using JERSEY and JAX-RS, persistence implemented in JPA
https://github.com/nunum/rest-server-java-skeleton

database http-rest-api java jax-rs jersey jpa log4j rest-api rest-java-skeleton rest-server starting-out-with-java swagger swagger-java

Last synced: about 1 month ago
JSON representation

MVC Rest server in JAVA, using JERSEY and JAX-RS, persistence implemented in JPA

Awesome Lists containing this project

README

        

# REST Server in Java - Starter Application

Rest server in JAVA, using JERSEY and JAX-RS, persistence implemented in JPA and also Swagger for auto-generated documentation in a non-servlet environment making this application is an excellent starting point to build your application.

## Important Aspects

- AppSettings class is reponsable to hold your start up settings application.

- The persistence is decoupled from the database, you can save your data on every database you want, in AppSettings is declarated the Repository factory that PersistenceContext instantiates in runtime using reflection.

- The database in use is [H2](https://www.h2database.com/html/main.html), which we can use as a volatile database because it has the option to run in [memory](https://github.com/NunuM/rest-server-java-skeleton/blob/master/src/main/resources/META-INF/persistence.xml#L13), in other words, each application shutdown erases all the data. This can be modified by changing the [jdbc database connection string](https://alvinalexander.com/java/jdbc-connection-string-mysql-postgresql-sqlserver)

- The Javax Persistence implementation is provided by the [eclipse link](https://www.eclipse.org/eclipselink/documentation/2.7/)

## Run

- With **maven**, build the project with the following command:

```bash
mvn package
```

- Finnaly, to **run the application**:
```bash
java -jar target/app/app.jar
```

## Example

The application when starts it bootstraps some actors and we can check them by:

```bash
curl http://localhost:8080/actor
```

or opening our browser: http://localhost:8080/actor to see the result.

## Swagger:

This starter application alread comes with swagger that can generate automatic documentation on a Java server without having a servlet container.

```bash
curl http://localhost:8080/swagger/swagger.json
```

or in your browser: http://localhost:8080/swagger/swagger.json

Open an issue if you find any problem :+1: