How to run Spring Boot application in Eclipse

spring boot reference properties and how to deploy spring boot application in tomcat and how spring boot configuration works and spring boot reference documentation pdf
LexiWills Profile Pic
LexiWills,United Kingdom,Professional
Published Date:01-08-2017
Your Website URL(Optional)
Comment
Spring Boot Reference Guide 2.0.0.BUILD-SNAPSHOT Phillip Webb , Dave Syer , Josh Long , Stéphane Nicoll , Rob Winch , Andy Wilkinson , Marcel Overdijk , Christian Dupuis , Sébastien Deleuze , Michael Simons , Vedran Pavi Copyright © 2012-2017 Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically.Spring Boot Reference Guide Table of Contents I. Spring Boot Documentation ...................................................................................................... 1 1. About the documentation . ............................................................................................... 2 2. Getting help . ................................................................................................................... 3 3. First steps . ..................................................................................................................... 4 4. Working with Spring Boot . ............................................................................................... 5 5. Learning about Spring Boot features ................................................................................ 6 6. Moving to production . ...................................................................................................... 7 7. Advanced topics ............................................................................................................. 8 II. Getting started . ....................................................................................................................... 9 8. Introducing Spring Boot ................................................................................................. 10 9. System Requirements . .................................................................................................. 11 9.1. Servlet containers . .............................................................................................. 11 10. Installing Spring Boot . ................................................................................................. 12 10.1. Installation instructions for the Java developer ................................................... 12 Maven installation ............................................................................................. 12 Gradle installation ............................................................................................. 13 10.2. Installing the Spring Boot CLI ........................................................................... 14 Manual installation ............................................................................................ 14 Installation with SDKMAN . ................................................................................ 14 OSX Homebrew installation ............................................................................... 15 MacPorts installation ......................................................................................... 15 Command-line completion . ................................................................................ 15 Quick start Spring CLI example . ........................................................................ 16 10.3. Upgrading from an earlier version of Spring Boot . .............................................. 16 11. Developing your first Spring Boot application . ............................................................... 17 11.1. Creating the POM ............................................................................................ 17 11.2. Adding classpath dependencies ........................................................................ 18 11.3. Writing the code . .............................................................................................. 19 The RestController and RequestMapping annotations .................................. 19 The EnableAutoConfiguration annotation ........................................................ 19 The “main” method ........................................................................................... 20 11.4. Running the example . ....................................................................................... 20 11.5. Creating an executable jar ................................................................................ 20 12. What to read next ....................................................................................................... 22 III. Using Spring Boot . ............................................................................................................... 23 13. Build systems ............................................................................................................. 24 13.1. Dependency management ................................................................................ 24 13.2. Maven .............................................................................................................. 24 Inheriting the starter parent . .............................................................................. 24 Using Spring Boot without the parent POM . ....................................................... 25 Using the Spring Boot Maven plugin .................................................................. 26 13.3. Gradle .............................................................................................................. 26 13.4. Ant ................................................................................................................... 26 13.5. Starters . ........................................................................................................... 27 14. Structuring your code .................................................................................................. 33 14.1. Using the “default” package .............................................................................. 33 14.2. Locating the main application class . .................................................................. 33 2.0.0.BUILD-SNAPSHOT Spring Boot iiSpring Boot Reference Guide 15. Configuration classes . ................................................................................................. 35 15.1. Importing additional configuration classes . ......................................................... 35 15.2. Importing XML configuration . ............................................................................. 35 16. Auto-configuration . ...................................................................................................... 36 16.1. Gradually replacing auto-configuration ............................................................... 36 16.2. Disabling specific auto-configuration .................................................................. 36 17. Spring Beans and dependency injection ....................................................................... 37 18. Using the SpringBootApplication annotation . ............................................................. 38 19. Running your application ............................................................................................. 39 19.1. Running from an IDE ........................................................................................ 39 19.2. Running as a packaged application . .................................................................. 39 19.3. Using the Maven plugin .................................................................................... 39 19.4. Using the Gradle plugin .................................................................................... 40 19.5. Hot swapping . .................................................................................................. 40 20. Developer tools ........................................................................................................... 41 20.1. Property defaults .............................................................................................. 41 20.2. Automatic restart . ............................................................................................. 42 Excluding resources .......................................................................................... 43 Watching additional paths .................................................................................. 43 Disabling restart ................................................................................................ 43 Using a trigger file . ........................................................................................... 44 Customizing the restart classloader . ................................................................... 44 Known limitations .............................................................................................. 44 20.3. LiveReload ....................................................................................................... 45 20.4. Global settings ................................................................................................. 45 20.5. Remote applications ......................................................................................... 45 Running the remote client application . ................................................................ 46 Remote update . ................................................................................................ 47 21. Packaging your application for production . .................................................................... 48 22. What to read next ....................................................................................................... 49 IV. Spring Boot features ............................................................................................................ 50 23. SpringApplication ......................................................................................................... 51 23.1. Startup failure ................................................................................................... 51 23.2. Customizing the Banner .................................................................................... 52 23.3. Customizing SpringApplication .......................................................................... 53 23.4. Fluent builder API ............................................................................................. 53 23.5. Application events and listeners ........................................................................ 54 23.6. Web environment . ............................................................................................ 54 23.7. Accessing application arguments . ...................................................................... 55 23.8. Using the ApplicationRunner or CommandLineRunner . ....................................... 55 23.9. Application exit ................................................................................................. 56 23.10. Admin features ............................................................................................... 56 24. Externalized Configuration . .......................................................................................... 57 24.1. Configuring random values . .............................................................................. 58 24.2. Accessing command line properties .................................................................. 58 24.3. Application property files ................................................................................... 59 24.4. Profile-specific properties . ................................................................................. 60 24.5. Placeholders in properties . ................................................................................ 61 24.6. Using YAML instead of Properties ..................................................................... 61 Loading YAML .................................................................................................. 61 2.0.0.BUILD-SNAPSHOT Spring Boot iiiSpring Boot Reference Guide Exposing YAML as properties in the Spring Environment . ................................... 62 Multi-profile YAML documents ........................................................................... 62 YAML shortcomings . ......................................................................................... 63 Merging YAML lists . .......................................................................................... 63 24.7. Type-safe Configuration Properties .................................................................... 64 Third-party configuration .................................................................................... 67 Relaxed binding ................................................................................................ 67 Properties conversion . ....................................................................................... 68 ConfigurationProperties Validation .................................................................. 69 ConfigurationProperties vs. Value ............................................................... 70 25. Profiles . ...................................................................................................................... 71 25.1. Adding active profiles . ...................................................................................... 71 25.2. Programmatically setting profiles . ...................................................................... 71 25.3. Profile-specific configuration files . ...................................................................... 72 26. Logging ....................................................................................................................... 73 26.1. Log format . ...................................................................................................... 73 26.2. Console output ................................................................................................. 73 Color-coded output . ........................................................................................... 74 26.3. File output . ....................................................................................................... 75 26.4. Log Levels ....................................................................................................... 75 26.5. Custom log configuration . ................................................................................. 76 26.6. Logback extensions .......................................................................................... 77 Profile-specific configuration . ............................................................................. 78 Environment properties . ..................................................................................... 78 27. Developing web applications ........................................................................................ 79 27.1. The ‘Spring Web MVC framework’ .................................................................... 79 Spring MVC auto-configuration .......................................................................... 79 HttpMessageConverters .................................................................................... 80 Custom JSON Serializers and Deserializers . ...................................................... 80 MessageCodesResolver .................................................................................... 81 Static Content ................................................................................................... 81 Custom Favicon . ............................................................................................... 83 ConfigurableWebBindingInitializer ...................................................................... 83 Template engines .............................................................................................. 83 Error Handling . ................................................................................................. 83 Custom error pages . ................................................................................. 84 Mapping error pages outside of Spring MVC . ............................................. 85 Error Handling on WebSphere Application Server ....................................... 85 Spring HATEOAS .............................................................................................. 86 CORS support .................................................................................................. 86 27.2. The ‘Spring WebFlux framework’ ....................................................................... 86 Spring WebFlux auto-configuration ..................................................................... 87 HTTP codecs with HttpMessageReaders and HttpMessageWriters ...................... 88 Static Content ................................................................................................... 88 Template engines . ............................................................................................. 89 27.3. JAX-RS and Jersey .......................................................................................... 89 27.4. Embedded servlet container support .................................................................. 90 Servlets, Filters, and listeners ............................................................................ 90 Registering Servlets, Filters, and listeners as Spring beans . ........................ 90 Servlet Context Initialization ............................................................................... 91 2.0.0.BUILD-SNAPSHOT Spring Boot ivSpring Boot Reference Guide Scanning for Servlets, Filters, and listeners . ............................................... 91 The ServletWebServerApplicationContext . .......................................................... 91 Customizing embedded servlet containers . ......................................................... 91 Programmatic customization ...................................................................... 92 Customizing ConfigurableServletWebServerFactory directly . ....................... 92 JSP limitations . ................................................................................................. 93 28. Security ...................................................................................................................... 94 28.1. OAuth2 . ........................................................................................................... 95 Authorization Server .......................................................................................... 95 Resource Server ............................................................................................... 95 28.2. Token Type in User Info . .................................................................................. 96 28.3. Customizing the User Info RestTemplate . .......................................................... 96 Client ................................................................................................................ 97 Single Sign On ................................................................................................. 98 28.4. Actuator Security .............................................................................................. 98 29. Working with SQL databases . .................................................................................... 100 29.1. Configure a DataSource .................................................................................. 100 Embedded Database Support . ......................................................................... 100 Connection to a production database . .............................................................. 101 Connection to a JNDI DataSource . .................................................................. 102 29.2. Using JdbcTemplate . ...................................................................................... 102 29.3. JPA and ‘Spring Data’ .................................................................................... 103 Entity Classes ................................................................................................. 103 Spring Data JPA Repositories . ......................................................................... 104 Creating and dropping JPA databases ............................................................. 105 Open EntityManager in View ........................................................................... 105 29.4. Using H2’s web console ................................................................................. 105 Changing the H2 console’s path . ..................................................................... 106 Securing the H2 console . ................................................................................ 106 29.5. Using jOOQ . .................................................................................................. 106 Code Generation ............................................................................................. 106 Using DSLContext . .......................................................................................... 106 jOOQ SQL dialect . .......................................................................................... 107 Customizing jOOQ .......................................................................................... 107 30. Working with NoSQL technologies . ............................................................................ 108 30.1. Redis ............................................................................................................. 108 Connecting to Redis ........................................................................................ 108 30.2. MongoDB ....................................................................................................... 108 Connecting to a MongoDB database ................................................................ 109 MongoTemplate .............................................................................................. 110 Spring Data MongoDB repositories . ................................................................. 110 Embedded Mongo . .......................................................................................... 110 30.3. Neo4j ............................................................................................................. 111 Connecting to a Neo4j database ...................................................................... 111 Using the embedded mode . ............................................................................. 111 Neo4jSession .................................................................................................. 112 Spring Data Neo4j repositories . ....................................................................... 112 Repository example ......................................................................................... 112 30.4. Gemfire . ......................................................................................................... 112 30.5. Solr ................................................................................................................ 113 2.0.0.BUILD-SNAPSHOT Spring Boot vSpring Boot Reference Guide Connecting to Solr .......................................................................................... 113 Spring Data Solr repositories ........................................................................... 113 30.6. Elasticsearch . ................................................................................................. 113 Connecting to Elasticsearch using Jest . ........................................................... 113 Connecting to Elasticsearch using Spring Data . ................................................ 114 Spring Data Elasticsearch repositories ............................................................. 114 30.7. Cassandra . ..................................................................................................... 114 Connecting to Cassandra ................................................................................ 115 Spring Data Cassandra repositories . ................................................................ 115 30.8. Couchbase . .................................................................................................... 115 Connecting to Couchbase . ............................................................................... 115 Spring Data Couchbase repositories ................................................................ 116 30.9. LDAP ............................................................................................................. 117 Connecting to an LDAP server . ....................................................................... 117 Spring Data LDAP repositories . ....................................................................... 117 Embedded in-memory LDAP server . ................................................................ 117 30.10. InfluxDB ....................................................................................................... 118 Connecting to InfluxDB .................................................................................... 118 31. Caching .................................................................................................................... 119 31.1. Supported cache providers ............................................................................. 120 Generic ........................................................................................................... 121 JCache (JSR-107) ........................................................................................... 121 EhCache 2.x . .................................................................................................. 122 Hazelcast . ....................................................................................................... 122 Infinispan . ....................................................................................................... 122 Couchbase ...................................................................................................... 122 Redis .............................................................................................................. 123 Caffeine . ......................................................................................................... 123 Simple . ........................................................................................................... 123 None ............................................................................................................... 124 32. Messaging . ............................................................................................................... 125 32.1. JMS ............................................................................................................... 125 ActiveMQ support ............................................................................................ 125 Artemis support . .............................................................................................. 126 Using a JNDI ConnectionFactory . .................................................................... 126 Sending a message ........................................................................................ 126 Receiving a message . ..................................................................................... 127 32.2. AMQP . ........................................................................................................... 128 RabbitMQ support ........................................................................................... 128 Sending a message ........................................................................................ 128 Receiving a message . ..................................................................................... 129 32.3. Apache Kafka Support .................................................................................... 130 Sending a Message ........................................................................................ 131 Receiving a Message . ..................................................................................... 131 Additional Kafka Properties .............................................................................. 131 33. Calling REST services with ‘RestTemplate’ . ................................................................ 133 33.1. RestTemplate customization . ........................................................................... 133 34. Calling REST services with ‘WebClient’ . ..................................................................... 135 34.1. WebClient customization . ................................................................................ 135 35. Validation . ................................................................................................................. 136 2.0.0.BUILD-SNAPSHOT Spring Boot viSpring Boot Reference Guide 36. Sending email . .......................................................................................................... 137 37. Distributed Transactions with JTA .............................................................................. 138 37.1. Using an Atomikos transaction manager . ......................................................... 138 37.2. Using a Bitronix transaction manager .............................................................. 138 37.3. Using a Narayana transaction manager . .......................................................... 139 37.4. Using a Java EE managed transaction manager .............................................. 139 37.5. Mixing XA and non-XA JMS connections . ........................................................ 139 37.6. Supporting an alternative embedded transaction manager ................................ 140 38. Hazelcast . ................................................................................................................. 141 39. Quartz Scheduler . ..................................................................................................... 142 40. Spring Integration ...................................................................................................... 143 41. Spring Session .......................................................................................................... 144 42. Monitoring and management over JMX ...................................................................... 145 43. Testing ...................................................................................................................... 146 43.1. Test scope dependencies ............................................................................... 146 43.2. Testing Spring applications . ............................................................................ 146 43.3. Testing Spring Boot applications ..................................................................... 146 Detecting test configuration .............................................................................. 147 Excluding test configuration . ............................................................................ 148 Working with random ports .............................................................................. 148 Mocking and spying beans . ............................................................................. 149 Auto-configured tests . ...................................................................................... 150 Auto-configured JSON tests ............................................................................. 150 Auto-configured Spring MVC tests ................................................................... 151 Auto-configured Spring WebFlux tests .............................................................. 153 Auto-configured Data JPA tests . ...................................................................... 154 Auto-configured JDBC tests . ............................................................................ 155 Auto-configured jOOQ tests . ............................................................................ 155 Auto-configured Data MongoDB tests . .............................................................. 156 Auto-configured Data Neo4j tests ..................................................................... 156 Auto-configured Data Redis tests . .................................................................... 157 Auto-configured Data LDAP tests ..................................................................... 157 Auto-configured REST clients .......................................................................... 158 Auto-configured Spring REST Docs tests . ........................................................ 158 Using Spock to test Spring Boot applications .................................................... 159 43.4. Test utilities . ................................................................................................... 160 ConfigFileApplicationContextInitializer . .............................................................. 160 EnvironmentTestUtils . ...................................................................................... 160 OutputCapture ................................................................................................. 160 TestRestTemplate ........................................................................................... 160 44. WebSockets .............................................................................................................. 162 45. Web Services ............................................................................................................ 163 46. Creating your own auto-configuration ......................................................................... 164 46.1. Understanding auto-configured beans . ............................................................. 164 46.2. Locating auto-configuration candidates . ........................................................... 164 46.3. Condition annotations ..................................................................................... 164 Class conditions . ............................................................................................. 165 Bean conditions .............................................................................................. 165 Property conditions .......................................................................................... 166 Resource conditions ........................................................................................ 166 2.0.0.BUILD-SNAPSHOT Spring Boot viiSpring Boot Reference Guide Web application conditions . ............................................................................. 166 SpEL expression conditions ............................................................................. 166 46.4. Creating your own starter . ............................................................................... 166 Naming ........................................................................................................... 166 Autoconfigure module . ..................................................................................... 167 Starter module . ............................................................................................... 167 47. What to read next ..................................................................................................... 168 V. Spring Boot Actuator: Production-ready features .................................................................. 169 48. Enabling production-ready features ............................................................................ 170 49. Endpoints . ................................................................................................................. 171 49.1. Customizing endpoints .................................................................................... 172 49.2. Hypermedia for actuator MVC endpoints .......................................................... 173 49.3. CORS support ................................................................................................ 173 49.4. Adding custom endpoints ................................................................................ 173 49.5. Health information . ......................................................................................... 174 49.6. Security with HealthIndicators ......................................................................... 174 Auto-configured HealthIndicators . ..................................................................... 174 Writing custom HealthIndicators . ...................................................................... 175 49.7. Application information . ................................................................................... 176 Auto-configured InfoContributors ...................................................................... 176 Custom application info information . ................................................................. 176 Git commit information ..................................................................................... 177 Build information . ............................................................................................ 177 Writing custom InfoContributors . ...................................................................... 177 50. Monitoring and management over HTTP .................................................................... 179 50.1. Accessing sensitive endpoints ......................................................................... 179 50.2. Customizing the management endpoint paths . ................................................. 180 50.3. Customizing the management server port . ....................................................... 180 50.4. Configuring management-specific SSL ............................................................. 181 50.5. Customizing the management server address . ................................................. 181 50.6. Disabling HTTP endpoints ............................................................................... 181 50.7. HTTP health endpoint format and access restrictions ........................................ 181 51. Monitoring and management over JMX ...................................................................... 183 51.1. Customizing MBean names . ............................................................................ 183 51.2. Disabling JMX endpoints . ................................................................................ 183 51.3. Using Jolokia for JMX over HTTP . .................................................................. 183 Customizing Jolokia . ........................................................................................ 183 Disabling Jolokia . ............................................................................................ 183 52. Loggers ..................................................................................................................... 185 52.1. Configure a Logger ......................................................................................... 185 53. Metrics . ..................................................................................................................... 186 53.1. System metrics ............................................................................................... 186 53.2. DataSource metrics . ....................................................................................... 187 53.3. Cache metrics ................................................................................................ 187 53.4. Tomcat session metrics . ................................................................................. 188 53.5. Recording your own metrics ............................................................................ 188 53.6. Adding your own public metrics . ...................................................................... 188 53.7. Metric writers, exporters and aggregation ......................................................... 189 Example: Export to Redis ................................................................................ 189 Example: Export to Open TSDB . ..................................................................... 190 2.0.0.BUILD-SNAPSHOT Spring Boot viiiSpring Boot Reference Guide Example: Export to Statsd . .............................................................................. 191 Example: Export to JMX .................................................................................. 191 53.8. Aggregating metrics from multiple sources . ...................................................... 191 53.9. Dropwizard Metrics ......................................................................................... 192 53.10. Message channel integration . ........................................................................ 192 54. Auditing . .................................................................................................................... 193 55. Tracing ..................................................................................................................... 194 55.1. Custom tracing . .............................................................................................. 194 56. Process monitoring .................................................................................................... 195 56.1. Extend configuration ....................................................................................... 195 56.2. Programmatically . ........................................................................................... 195 57. Cloud Foundry support . ............................................................................................. 196 57.1. Disabling extended Cloud Foundry actuator support . ........................................ 196 57.2. Cloud Foundry self signed certificates ............................................................. 196 57.3. Custom security configuration ......................................................................... 196 58. What to read next . .................................................................................................... 197 VI. Deploying Spring Boot applications . .................................................................................... 198 59. Deploying to the cloud ............................................................................................... 199 59.1. Cloud Foundry ................................................................................................ 199 Binding to services . ......................................................................................... 200 59.2. Heroku . .......................................................................................................... 201 59.3. OpenShift . ...................................................................................................... 202 59.4. Amazon Web Services (AWS) . ........................................................................ 202 AWS Elastic Beanstalk . ................................................................................... 203 Using the Tomcat platform . ...................................................................... 203 Using the Java SE platform ..................................................................... 203 Best practices . ........................................................................................ 203 Summary . ....................................................................................................... 203 59.5. Boxfuse and Amazon Web Services . ............................................................... 203 59.6. Google Cloud ................................................................................................. 204 60. Installing Spring Boot applications . ............................................................................. 206 60.1. Supported operating systems . ......................................................................... 206 60.2. Unix/Linux services . ........................................................................................ 206 Installation as an init.d service (System V) . ...................................................... 206 Securing an init.d service ........................................................................ 207 Installation as a systemd service ..................................................................... 208 Customizing the startup script .......................................................................... 208 Customizing script when it’s written . ......................................................... 209 Customizing script when it runs ............................................................... 210 60.3. Microsoft Windows services . ........................................................................... 211 61. What to read next ..................................................................................................... 212 VII. Spring Boot CLI . ............................................................................................................... 213 62. Installing the CLI . ...................................................................................................... 214 63. Using the CLI ............................................................................................................ 215 63.1. Running applications using the CLI . ................................................................ 215 Deduced “grab” dependencies ......................................................................... 216 Deduced “grab” coordinates ............................................................................. 217 Default import statements ................................................................................ 217 Automatic main method ................................................................................... 217 Custom dependency management . .................................................................. 217 2.0.0.BUILD-SNAPSHOT Spring Boot ixSpring Boot Reference Guide 63.2. Applications with multiple source files . ............................................................. 218 63.3. Packaging your application ............................................................................. 218 63.4. Initialize a new project .................................................................................... 218 63.5. Using the embedded shell . ............................................................................. 219 63.6. Adding extensions to the CLI .......................................................................... 219 64. Developing application with the Groovy beans DSL ..................................................... 220 65. Configuring the CLI with settings.xml . ......................................................................... 221 66. What to read next ..................................................................................................... 222 VIII. Build tool plugins ............................................................................................................. 223 67. Spring Boot Maven plugin . ......................................................................................... 224 67.1. Including the plugin . ....................................................................................... 224 67.2. Packaging executable jar and war files ............................................................ 225 68. Spring Boot Gradle plugin . ......................................................................................... 226 69. Spring Boot AntLib module ........................................................................................ 227 69.1. Spring Boot Ant tasks ..................................................................................... 227 spring-boot:exejar . ........................................................................................... 227 Examples . ....................................................................................................... 227 69.2. spring-boot:findmainclass . ............................................................................... 228 Examples . ....................................................................................................... 228 70. Supporting other build systems . ................................................................................. 229 70.1. Repackaging archives ..................................................................................... 229 70.2. Nested libraries . ............................................................................................. 229 70.3. Finding a main class ....................................................................................... 229 70.4. Example repackage implementation . ............................................................... 229 71. What to read next . .................................................................................................... 230 IX. ‘How-to’ guides . ................................................................................................................. 231 72. Spring Boot application . ............................................................................................. 232 72.1. Create your own FailureAnalyzer ..................................................................... 232 72.2. Troubleshoot auto-configuration ....................................................................... 232 72.3. Customize the Environment or ApplicationContext before it starts . ..................... 233 72.4. Build an ApplicationContext hierarchy (adding a parent or root context) . ............. 234 72.5. Create a non-web application .......................................................................... 234 73. Properties & configuration .......................................................................................... 235 73.1. Automatically expand properties at build time . .................................................. 235 Automatic property expansion using Maven ...................................................... 235 Automatic property expansion using Gradle ...................................................... 235 73.2. Externalize the configuration of SpringApplication ............................................. 236 73.3. Change the location of external properties of an application .............................. 237 73.4. Use ‘short’ command line arguments ............................................................... 237 73.5. Use YAML for external properties . ................................................................... 238 73.6. Set the active Spring profiles .......................................................................... 238 73.7. Change configuration depending on the environment . ....................................... 238 73.8. Discover built-in options for external properties . ............................................... 239 74. Embedded Web servers . ........................................................................................... 240 74.1. Use another Web server ................................................................................. 240 74.2. Configure Jetty ............................................................................................... 241 74.3. Add a Servlet, Filter or Listener to an application . ............................................. 241 Add a Servlet, Filter or Listener using a Spring bean ......................................... 241 Disable registration of a Servlet or Filter ................................................... 241 Add Servlets, Filters, and Listeners using classpath scanning . ........................... 242 2.0.0.BUILD-SNAPSHOT Spring Boot xSpring Boot Reference Guide 74.4. Change the HTTP port ................................................................................... 242 74.5. Use a random unassigned HTTP port . ............................................................. 242 74.6. Discover the HTTP port at runtime . ................................................................. 242 74.7. Configure SSL . ............................................................................................... 243 74.8. Configure Access Logging .............................................................................. 243 74.9. Use behind a front-end proxy server ................................................................ 243 Customize Tomcat’s proxy configuration . .......................................................... 244 74.10. Configure Tomcat . ........................................................................................ 244 74.11. Enable Multiple Connectors with Tomcat ........................................................ 245 74.12. Use Tomcat’s LegacyCookieProcessor . ......................................................... 245 74.13. Configure Undertow ...................................................................................... 245 74.14. Enable Multiple Listeners with Undertow . ....................................................... 246 74.15. Create WebSocket endpoints using ServerEndpoint .................................... 246 74.16. Enable HTTP response compression . ............................................................ 246 75. Spring MVC .............................................................................................................. 247 75.1. Write a JSON REST service ........................................................................... 247 75.2. Write an XML REST service ........................................................................... 247 75.3. Customize the Jackson ObjectMapper ............................................................. 247 75.4. Customize the ResponseBody rendering ...................................................... 249 75.5. Handling Multipart File Uploads ....................................................................... 249 75.6. Switch off the Spring MVC DispatcherServlet . .................................................. 249 75.7. Switch off the Default MVC configuration ......................................................... 250 75.8. Customize ViewResolvers ............................................................................... 250 76. HTTP clients ............................................................................................................. 252 76.1. Configure RestTemplate to use a proxy . .......................................................... 252 77. Logging . .................................................................................................................... 253 77.1. Configure Logback for logging ......................................................................... 253 Configure logback for file only output ............................................................... 254 77.2. Configure Log4j for logging ............................................................................. 254 Use YAML or JSON to configure Log4j 2 . ........................................................ 255 78. Data Access ............................................................................................................. 256 78.1. Configure a custom DataSource ...................................................................... 256 78.2. Configure Two DataSources ........................................................................... 258 78.3. Use Spring Data repositories . ......................................................................... 259 78.4. Separate Entity definitions from Spring configuration . .................................... 259 78.5. Configure JPA properties . ............................................................................... 259 78.6. Configure Hibernate Naming Strategy .............................................................. 260 78.7. Use a custom EntityManagerFactory ............................................................... 260 78.8. Use Two EntityManagers ................................................................................ 260 78.9. Use a traditional persistence.xml ..................................................................... 261 78.10. Use Spring Data JPA and Mongo repositories ................................................ 261 78.11. Expose Spring Data repositories as REST endpoint . ....................................... 262 78.12. Configure a component that is used by JPA ................................................... 262 79. Database initialization ................................................................................................ 263 79.1. Initialize a database using JPA ....................................................................... 263 79.2. Initialize a database using Hibernate . .............................................................. 263 79.3. Initialize a database using Spring JDBC .......................................................... 263 79.4. Initialize a Spring Batch database ................................................................... 264 79.5. Use a higher-level database migration tool . ...................................................... 264 Execute Flyway database migrations on startup . ............................................... 264 2.0.0.BUILD-SNAPSHOT Spring Boot xiSpring Boot Reference Guide Execute Liquibase database migrations on startup . ........................................... 265 80. Messaging . ............................................................................................................... 266 80.1. Disable transacted JMS session ...................................................................... 266 81. Batch applications . .................................................................................................... 267 81.1. Execute Spring Batch jobs on startup . ............................................................. 267 82. Actuator .................................................................................................................... 268 82.1. Change the HTTP port or address of the actuator endpoints ............................. 268 82.2. Customize the ‘whitelabel’ error page .............................................................. 268 82.3. Actuator and Jersey . ....................................................................................... 268 83. Security ..................................................................................................................... 269 83.1. Switch off the Spring Boot security configuration .............................................. 269 83.2. Change the AuthenticationManager and add user accounts . ............................. 269 83.3. Enable HTTPS when running behind a proxy server . ........................................ 269 84. Hot swapping . ........................................................................................................... 271 84.1. Reload static content . ..................................................................................... 271 84.2. Reload templates without restarting the container ............................................. 271 Thymeleaf templates . ...................................................................................... 271 FreeMarker templates ...................................................................................... 271 Groovy templates . ........................................................................................... 271 84.3. Fast application restarts . ................................................................................. 271 84.4. Reload Java classes without restarting the container . ....................................... 271 85. Build ......................................................................................................................... 272 85.1. Generate build information .............................................................................. 272 85.2. Generate git information . ................................................................................. 272 85.3. Customize dependency versions ..................................................................... 273 85.4. Create an executable JAR with Maven . ........................................................... 273 85.5. Use a Spring Boot application as a dependency . .............................................. 274 85.6. Extract specific libraries when an executable jar runs . ...................................... 274 85.7. Create a non-executable JAR with exclusions . ................................................. 275 85.8. Remote debug a Spring Boot application started with Maven . ............................ 275 85.9. Build an executable archive from Ant without using spring-boot-antlib ................ 276 86. Traditional deployment ............................................................................................... 277 86.1. Create a deployable war file ........................................................................... 277 86.2. Create a deployable war file for older servlet containers . ................................... 278 86.3. Convert an existing application to Spring Boot .................................................. 278 86.4. Deploying a WAR to WebLogic . ...................................................................... 280 86.5. Deploying a WAR in an Old (Servlet 2.5) Container .......................................... 280 86.6. Use Lettuce instead of Jedis ........................................................................... 281 X. Appendices . ........................................................................................................................ 283 A. Common application properties ................................................................................... 284 B. Configuration meta-data . ............................................................................................. 307 B.1. Meta-data format . ............................................................................................. 307 Group Attributes . ............................................................................................. 308 Property Attributes . .......................................................................................... 309 Hint Attributes ................................................................................................. 311 Repeated meta-data items . .............................................................................. 311 B.2. Providing manual hints ..................................................................................... 312 Value hint ....................................................................................................... 312 Value provider . ................................................................................................ 312 Any ......................................................................................................... 313 2.0.0.BUILD-SNAPSHOT Spring Boot xiiSpring Boot Reference Guide Class reference ....................................................................................... 314 Handle As ............................................................................................... 314 Logger name . ......................................................................................... 315 Spring bean reference ............................................................................. 316 Spring profile name . ................................................................................ 317 B.3. Generating your own meta-data using the annotation processor .......................... 317 Nested properties . ........................................................................................... 318 Adding additional meta-data . ........................................................................... 318 C. Auto-configuration classes . .......................................................................................... 320 C.1. From the “spring-boot-autoconfigure” module .................................................... 320 C.2. From the “spring-boot-actuator” module . ........................................................... 323 D. Test auto-configuration annotations ............................................................................. 325 E. The executable jar format ........................................................................................... 327 E.1. Nested JARs . .................................................................................................. 327 The executable jar file structure . ...................................................................... 327 The executable war file structure . .................................................................... 327 E.2. Spring Boot’s “JarFile” class ............................................................................. 328 Compatibility with the standard Java “JarFile” ................................................... 328 E.3. Launching executable jars ................................................................................ 328 Launcher manifest ........................................................................................... 329 Exploded archives . .......................................................................................... 329 E.4. PropertiesLauncher Features . ........................................................................... 329 E.5. Executable jar restrictions ................................................................................. 331 Zip entry compression ..................................................................................... 331 System ClassLoader . ...................................................................................... 331 E.6. Alternative single jar solutions . ......................................................................... 331 F. Dependency versions .................................................................................................. 332 2.0.0.BUILD-SNAPSHOT Spring Boot xiiiPart I. Spring Boot Documentation This section provides a brief overview of Spring Boot reference documentation. Think of it as map for the rest of the document. You can read this reference guide in a linear fashion, or you can skip sections if something doesn’t interest you.Spring Boot Reference Guide 1. About the documentation The Spring Boot reference guide is available as html, pdf and epub documents. The latest copy is available at docs.spring.io/spring-boot/docs/current/reference. Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically. 2.0.0.BUILD-SNAPSHOT Spring Boot 2Spring Boot Reference Guide 2. Getting help Having trouble with Spring Boot, We’d like to help • Try the How-to’s — they provide solutions to the most common questions. • Learn the Spring basics — Spring Boot builds on many other Spring projects, check the spring.io web- site for a wealth of reference documentation. If you are just starting out with Spring, try one of the guides. • Ask a question - we monitor stackoverflow.com for questions tagged with spring-boot. • Report bugs with Spring Boot at github.com/spring-projects/spring-boot/issues. Note All of Spring Boot is open source, including the documentation If you find problems with the docs; or if you just want to improve them, please get involved. 2.0.0.BUILD-SNAPSHOT Spring Boot 3Spring Boot Reference Guide 3. First steps If you’re just getting started with Spring Boot, or 'Spring' in general, this is the place to start • From scratch: Overview Requirements Installation • Tutorial: Part 1 Part 2 • Running your example: Part 1 Part 2 2.0.0.BUILD-SNAPSHOT Spring Boot 4Spring Boot Reference Guide 4. Working with Spring Boot Ready to actually start using Spring Boot? We’ve got you covered. • Build systems: Maven Gradle Ant Starters • Best practices: Code Structure Configuration EnableAutoConfiguration Beans and Dependency Injection • Running your code IDE Packaged Maven Gradle • Packaging your app: Production jars • Spring Boot CLI: Using the CLI 2.0.0.BUILD-SNAPSHOT Spring Boot 5Spring Boot Reference Guide 5. Learning about Spring Boot features Need more details about Spring Boot’s core features? This is for you • Core Features: SpringApplication External Configuration Profiles Logging • Web Applications: MVC Embedded Containers • Working with data: SQL NO-SQL • Messaging: Overview JMS • Testing: Overview Boot Applications Utils • Extending: Auto-configuration Conditions 2.0.0.BUILD-SNAPSHOT Spring Boot 6Spring Boot Reference Guide 6. Moving to production When you’re ready to push your Spring Boot application to production, we’ve got some tricks that you might like • Management endpoints: Overview Customization • Connection options: HTTP JMX • Monitoring: Metrics Auditing Tracing Process 2.0.0.BUILD-SNAPSHOT Spring Boot 7

Advise: Why You Wasting Money in Costly SEO Tools, Use World's Best Free SEO Tool Ubersuggest.