Skip to content

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

License

Notifications You must be signed in to change notification settings

NunuM/rest-server-java-skeleton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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, which we can use as a volatile database because it has the option to run in memory, in other words, each application shutdown erases all the data. This can be modified by changing the jdbc database connection string

  • The Javax Persistence implementation is provided by the eclipse link

Run

  • With maven, build the project with the following command:
 mvn package
  • Finnaly, to run the application:
java -jar target/app/app.jar

Example

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

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.

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 👍