Skip to content

database-audits/spring-boot-integration

Repository files navigation

Database Audits — Spring Boot Integration

Spring Boot wiring for database-audits-core. One @Import registers every audit bean, their collaborators, and the SQL-capturing StatementInspector — enabling catalog, JPA, and runtime audits in any @SpringBootTest context.

Getting started

The fastest path is to let the archetype generate the audit test suite directly into your project:

# Run from your project root. Adjust -Dpackage and -DschemaName to match your project.
mvn archetype:generate -DinteractiveMode=false \
  -DarchetypeGroupId=io.github.database-audits \
  -DarchetypeArtifactId=database-audits-spring-boot-integration-archetype \
  -DarchetypeVersion=1.0.0-SNAPSHOT \
  -DgenerateMode=tests-only \
  -Dpackage=com.example.demo \
  -DschemaName=public \
  -DoutputDirectory=/tmp/audit-scratch \
  -DprojectDirectory=.

This copies the full audit IT suite into your src/test/ tree — no pom.xml, no demo harness, ready to run against your existing Spring Boot test context. Add the database-audits-spring-boot-integration dependency to your pom.xml and run mvn verify.

Use generateMode=project to generate a complete standalone example with a Testcontainers PostgreSQL harness. See Archetype for all properties and modes.

For manual wiring without the archetype, see the Overview.

Documentation

Full documentation is published at database-audits.github.io/spring-boot:

  • Overview — dependency, quick start, audit families

  • Usage — prerequisites, enabling audits, ordering runtime tests

  • Audits — what each audit detects

  • Exclusions — suppressing known violations

  • Archetype — generate an audit suite into your project

Building

Requires JDK 21 and Docker (for the archetype end-to-end test).

.\mvnw.cmd clean install

The archetype module generates the example suite and runs it against a Testcontainers PostgreSQL container. See CI for build status.