Skip to content

fillmore-labs/spring-data

Repository files navigation

Spring Data Playground

Structure

Spring Configuration

Spring Boot is configured in com.fillmore_labs.example.spring_data.main. DatabaseConfiguration is separated to be easily referenced in tests.

💡
For a more fine-grained approach and a little extra speed, and we use …​Marker-classes (see basePackageClasses) and spring-context-indexer.

Application Configuration

The Application is configured in com.fillmore_labs.example.spring_data.config, currently only used in HelloWorld.

It’s just an example to demonstrate custom typesafe, @Immutable configuration with Spring.

💡
Since a configuration is a Spring Bean, we can either use Jakarta Bean Validation 2.0, or the parameters could be validated in the constructor.

Jakarta Persistence

ℹ️
For equals() and hashCode() see the references.

Spring Data

Spring Data REST repositories are defined in com.fillmore_labs.example.spring_data.repository and are automatically exported.

Running

Prerequisites

You need Bazelisk installed, see also Installing Bazel using Bazelisk.

macOS

Using HomeBrew enter

brew install bazelisk

Windows

Using Chocolatey enter

choco install bazelisk

Enable developer mode:

  1. Open Windows settings

  2. Go to “Update & security”, then “For developers”

  3. Under “Developer Mode” section enable “Install apps from any source, including loose files”.

or run with administrator privileges.

Main App

The main app simply runs two CommandLineRunners, HelloWorld and Create:

bazelisk run //:spring-data

When you want to try the REST API, Spring Data REST HAL Explorer at http://127.0.0.1:8080/ and the H2 console at http://127.0.0.1:8080/h2-console (JDBC URL is jdbc:h2:mem:testdb), run

bazelisk run //:spring-data-rest

Tests

To run all tests, use

bazelisk test //src/test/...