This example demonstrates Micronaut Data using SQL/JDBC and is adapted from the example-jdbc example offered by Micronaut Data.
src/main/java/org/redlich/movies/domain- Entities that map onto database tables.src/main/java/org/redlich/movies/repositories- Micronaut Data Repository interfaces.src/main/java/org/redlich/movies/controllers- Controllers that are injected with the repository interfaces.src/test/java/org/redlich/movies- JUnit 5 tests that test the application.
The example is configured to use an in-memory H2 database via src/main/resources/application.yml.
The schema is set to generate automatically using the schema-generate: CREATE_DROP setting.
Query logging is enabled in src/main/resources/logback.xml via:
<logger name="io.micronaut.data.query" level="debug" />You can run the tests with either ./gradlew test for Gradle or ./mvnw test for Maven.
The application can be run with either ./gradlew run or ./mvnw compile exec:exec.
Alternatively you can import the example into either IntelliJ, Visual Studio Code or Eclipse.
$ curl -w "\n" http://localhost:8080/movies/The%20Green%20MileA native image can be built by installing GraalVM 19.1 or above and running the following for Gradle:
$ ./gradlew assemble
$ native-image --no-server -cp build/libs/micronaut-movies-0.1-all.jarOr for Maven:
$ ./mvnw package
$ native-image --no-server -cp target/micronaut-movies-0.1.jar