Rest service template for CSI code review assignment

Rest service template for the code review assignment of the Information Systems Quality course - GEI - UDC.

The template uses Spring Boot.

The template includes a simple entity and a controller. It also includes some sample test for the controller. The list of test is not comprehensive and should not be considered good enough for a real application.

Requirements:

  • Java 17

Compiling, testing, packaging and running the application

The application comes with a provided maven-wrapper. A local installation of Apache Maven can be used instead, but is not mandatory. The rest of the document uses a local installation of maven for brevity. To used the provided maven-wrapper substitute the call to the mvn command with mvnw.cmd in Windows and ./mvnw in Mac and Linux.

The application can be compiled, the tests can be run and the application can be packaged using the standard maven phases

To compile:

mvn compile

To run the test:

mvn test

To package the application:

mvn package

The packaged application is configured by the spring boot plugin to include all the necessary dependencies and can be run as a standalone application (substituting GROUP and VERSION for the appropriate values):

java -jar target/base-rest-GROUP-VERSION.jar

The Spring Boot Maven plugin can also be used to launch the application without the need for packaging it:

mvn spring-boot:run

Configuring the database

The template default configuration uses an in-memory H2 database, whose contents will be lost when the application closes. The project also has a profile to use an H2 database backed by a file in the hard drive. To use this profile we have to switch it in the maven command line:

mvn -P h2-disk spring-boot:run

The same can be done when packaging the application:

mvn -P h2-disk package

The location of the database file can be configured in the application-persistence-h2-disk.properties file in the src/main/resources folder

More info

The template includes HELP.md, a file generated by the Spring Initializer with some useful links to Spring documentation

Template credits

  • Alfonso Landín
  • Javier Parapar
  • Anxo Pérez