Spring Boot provides the application shell for several database-backed Spring projects. A project generated with Spring Initializr supplies a main class, a test class, an initially empty application.properties file, and a Maven pom.xml. Choose starters according to the job: Spring Data JPA or Spring Data JDBC for persistence, and Spring Web plus REST Repositories when repositories need a REST interface. section 4.2 section 15.1 section 16.2
For a MySQL-backed application, complete the generated project in this order:
- Add the relevant Spring Data starter and MySQL driver to pom.xml. A JPA project uses spring-boot-starter-data-jpa; a JDBC project uses spring-boot-starter-data-jdbc. section 4.2 section 15.1
- Set the datasource URL and credentials in application.properties. Spring Boot loads this file from the classpath; Maven places src/main/resources there. Replace example credentials for your environment. section 15.1 section 16.2
- Decide how the schema is initialized. For a MySQL Spring Data JDBC example, spring.sql.init.mode=always makes classpath schema.sql and data.sql run at startup; the shown schema script drops and recreates USERS. section 15.1
A REST-backed persistence application
A Spring Data REST project combines spring-boot-starter-web, spring-boot-starter-data-jpa, spring-boot-starter-data-rest, and the MySQL driver. Its application class uses @SpringBootApplication and SpringApplication.run(...); an ApplicationRunner saves users through a JpaRepository at startup. With server.port=8081, an example request is GET http://localhost:8081/users/1. This setup connects project dependencies, configuration, startup work, and a browser-accessible repository interface. section 16.2
Treat configuration as operational behavior, not just setup. The examples configure SQL visibility, database dialect, and schema creation in application.properties; choosing startup schema recreation or unconditional SQL initialization affects existing data. Parameters can also come from source code or command-line arguments rather than a properties file. For persistence tests, the generated project adds Spring Data JPA, validation, the MySQL driver, and a test starter. section 15.1 section 16.2 section 20.2



