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.
-
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
- With maven, build the project with the following command:
mvn package
- Finnaly, to run the application:
java -jar target/app/app.jar
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.
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 👍