Spring Boot Reference Documentation
Total Page:16
File Type:pdf, Size:1020Kb
Spring Boot Reference Documentation Phillip Webb, Dave Syer, Josh Long, Stéphane Nicoll, Rob Winch, Andy Wilkinson, Marcel Overdijk, Christian Dupuis, Sébastien Deleuze, Michael Simons, Vedran Pavić, Jay Bryant, Madhura Bhave Table of Contents Legal. 1 1. Spring Boot Documentation. 2 1.1. About the Documentation. 2 1.2. Getting Help . 2 1.3. First Steps . 2 1.4. Working with Spring Boot . 2 1.5. Learning about Spring Boot Features . 3 1.6. Moving to Production . 3 1.7. Advanced Topics . 3 2. Getting Started . 4 2.1. Introducing Spring Boot . 4 2.2. System Requirements . 4 2.2.1. Servlet Containers. 4 2.3. Installing Spring Boot . 5 2.3.1. Installation Instructions for the Java Developer . 5 Maven Installation . 5 Gradle Installation . 7 2.3.2. Installing the Spring Boot CLI . 7 Manual Installation . 7 Installation with SDKMAN!. 8 OSX Homebrew Installation . 8 MacPorts Installation . 9 Command-line Completion . 9 Windows Scoop Installation . 9 Quick-start Spring CLI Example. 9 2.3.3. Upgrading from an Earlier Version of Spring Boot . 10 2.4. Developing Your First Spring Boot Application . 11 2.4.1. Creating the POM . 11 2.4.2. Adding Classpath Dependencies . 12 2.4.3. Writing the Code . 13 The @RestController and @RequestMapping Annotations . 14 The @EnableAutoConfiguration Annotation . 14 The “main” Method . 15 2.4.4. Running the Example. 15 2.4.5. Creating an Executable Jar . 15 2.5. What to Read Next . 17 3. Using Spring Boot . 19 3.1. Build Systems. 19 3.1.1. Dependency Management . 19 3.1.2. Maven . 19 Inheriting the Starter Parent . 20 Using Spring Boot without the Parent POM . 20 Using the Spring Boot Maven Plugin . 21 3.1.3. Gradle . 22 3.1.4. Ant . 22 3.1.5. Starters . 23 3.2. Structuring Your Code . 28 3.2.1. Using the “default” Package . 29 3.2.2. Locating the Main Application Class . 29 3.3. Configuration Classes . 30 3.3.1. Importing Additional Configuration Classes . 30 3.3.2. Importing XML Configuration . 30 3.4. Auto-configuration . 30 3.4.1. Gradually Replacing Auto-configuration . 31 3.4.2. Disabling Specific Auto-configuration Classes . 31 3.5. Spring Beans and Dependency Injection . ..