diff --git a/spring-boot-docs/pom.xml b/spring-boot-docs/pom.xml index 3e14fc95ee..4376d53462 100644 --- a/spring-boot-docs/pom.xml +++ b/spring-boot-docs/pom.xml @@ -200,7 +200,7 @@ org.asciidoctor asciidoctor-maven-plugin - 0.1.4 + 1.5.0 generate-docbook diff --git a/spring-boot-docs/src/main/asciidoc/appendix-executable-jar-format.adoc b/spring-boot-docs/src/main/asciidoc/appendix-executable-jar-format.adoc index 1e84be46b1..fab947d106 100644 --- a/spring-boot-docs/src/main/asciidoc/appendix-executable-jar-format.adoc +++ b/spring-boot-docs/src/main/asciidoc/appendix-executable-jar-format.adoc @@ -140,7 +140,7 @@ file and it's used to setup an appropriate `URLClassLoader` and ultimately call There are 3 launcher subclasses (`JarLauncher`, `WarLauncher` and `PropertiesLauncher`). Their purpose is to load resources (`.class` files etc.) from nested jar files or war files in directories (as opposed to explicitly on the classpath). In the case of the -`[Jar|War]Launcher` the nested paths are fixed `(lib/*.jar` and `lib-provided/*.jar` for +`[Jar|War]Launcher` the nested paths are fixed `(lib/\*.jar` and `lib-provided/\*.jar` for the war case) so you just add extra jars in those locations if you want more. The `PropertiesLauncher` looks in `lib/` by default, but you can add additional locations by setting an environment variable `LOADER_PATH` or `loader.path` in `application.properties` diff --git a/spring-boot-docs/src/main/asciidoc/howto.adoc b/spring-boot-docs/src/main/asciidoc/howto.adoc index b2bbc3e9f0..a0f71ad08c 100644 --- a/spring-boot-docs/src/main/asciidoc/howto.adoc +++ b/spring-boot-docs/src/main/asciidoc/howto.adoc @@ -1,9 +1,9 @@ [[howto]] -= ``How-to'' guides += '`How-to`' guides [partintro] -- -This section provides answers to some common '``how do I do that...''' type of questions +This section provides answers to some common '`how do I do that...`' type of questions that often arise when using Spring Boot. This is by no means an exhaustive list, but it does cover quite a lot. @@ -12,7 +12,7 @@ http://stackoverflow.com/tags/spring-boot[stackoverflow.com] to see if someone h already provided an answer; this is also a great place to ask new questions (please use the `spring-boot` tag). -We're also more than happy to extend this section; If you want to add a ``how-to'' you +We're also more than happy to extend this section; If you want to add a '`how-to`' you can send us a {github-code}[pull request]. -- @@ -25,7 +25,7 @@ can send us a {github-code}[pull request]. [[howto-troubleshoot-auto-configuration]] === Troubleshoot auto-configuration -The Spring Boot auto-configuration tries its best to ``do the right thing'', but +The Spring Boot auto-configuration tries its best to '`do the right thing`' , but sometimes things fail and it can be hard to tell why. There is a really useful `AutoConfigurationReport` available in any Spring Boot @@ -37,8 +37,8 @@ which not) by Spring Boot at runtime. Many more questions can be answered by looking at the source code and the javadoc. Some rules of thumb: -* Look for classes called `*AutoConfiguration` and read their sources, in particular the - `@Conditional*` annotations to find out what features they enable and when. Add +* Look for classes called `\*AutoConfiguration` and read their sources, in particular the + `@Conditional\*` annotations to find out what features they enable and when. Add `--debug` to the command line or a System property `-Ddebug` to get a log on the console of all the autoconfiguration decisions that were made in your app. In a running Actuator app look at the `autoconfig` endpoint (`/autoconfig' or the JMX equivalent) for @@ -80,7 +80,7 @@ The `SpringApplication` sends some special `ApplicationEvents` to the listeners some before the context is created), and then registers the listeners for events published by the `ApplicationContext` as well. See '<>' in the -``Spring Boot features'' section for a complete list. +'`Spring Boot features`' section for a complete list. @@ -88,7 +88,7 @@ by the `ApplicationContext` as well. See === Build an ApplicationContext hierarchy (adding a parent or root context) You can use the `ApplicationBuilder` class to create parent/child `ApplicationContext` hierarchies. See '<>' -in the ``Spring Boot features'' section for more information. +in the '`Spring Boot features`' section for more information. @@ -136,7 +136,7 @@ underscores (`_`) as well as dashes (`-`) in property names. === Change the location of external properties of an application By default properties from different sources are added to the Spring `Environment` in a defined order (see '<>' in -the ``Spring Boot features'' section for the exact order). +the '`Spring Boot features`' section for the exact order). A nice way to augment and modify this is to add `@PropertySource` annotations to your application sources. Classes passed to the `SpringApplication` static convenience @@ -156,7 +156,7 @@ You can also provide System properties (or environment variables) to change the command line. No matter what you set in the environment, Spring Boot will always load -`application.properties` as described above. If YAML is used then files with the ``.yml'' +`application.properties` as described above. If YAML is used then files with the '`.yml`' extension are also added to the list by default. See {sc-spring-boot}/context/config/ConfigFileApplicationListener.{sc-ext}[`ConfigFileApplicationListener`] @@ -165,7 +165,7 @@ for more detail. [[howto-use-short-command-line-arguments]] -=== Use ``short'' command line arguments +=== Use '`short`' command line arguments Some people like to use (for example) `--port=9000` instead of `--server.port=9000` to set configuration properties on the command line. You can easily enable this by using placeholders in `application.properties`, e.g. @@ -177,7 +177,7 @@ placeholders in `application.properties`, e.g. TIP: If you are inheriting from the `spring-boot-starter-parent` POM, or if have enabled maven filtering for the `application.properties` directly, you may want to change the -default filter token from `${*}` since it conflicts with those placeholders. +default filter token from `${\*}` since it conflicts with those placeholders. You can either use `@*@` (i.e. `@maven.token@` instead of `${maven.token}`) or you can configure the `maven-resources-plugin` to use http://maven.apache.org/plugins/maven-resources-plugin/resources-mojo.html#delimiters[other delimiters]. @@ -223,7 +223,7 @@ The example YAML above corresponds to an `application.properties` file ---- See '<>' in -the ``Spring Boot features'' section for more information +the '`Spring Boot features`' section for more information about YAML. [[howto-set-active-spring-profiles]] @@ -250,7 +250,7 @@ but not by the `SpringApplicationBuilder.profiles()` method. Thus the latter Jav be used to augment the profiles without changing the defaults. See '<>' in -the ``Spring Boot features'' section for more information. +the '`Spring Boot features`' section for more information. @@ -285,8 +285,8 @@ Example: port: 0 ---- -In this example the default port is 9000, but if the Spring profile ``development'' is -active then the port is 9001, and if ``production'' is active then it is 0. +In this example the default port is 9000, but if the Spring profile '`development`' is +active then the port is 9001, and if '`production`' is active then it is 0. The YAML documents are merged in the order they are encountered (so later values override earlier ones). @@ -346,7 +346,7 @@ To switch off the HTTP endpoints completely, but still create a `WebApplicationC use `server.port=-1` (this is sometimes useful for testing). For more details look at '<>' -in the ``Spring Boot features'' section, or the +in the '`Spring Boot features`' section, or the {sc-spring-boot-autoconfigure}/web/ServerProperties.{sc-ext}[`ServerProperties`] source code. @@ -366,7 +366,7 @@ that and be sure that it has initialized is to add a `@Bean` of type out of the event when it is published. A really useful thing to do in is to use `@IntegrationTest` to set `server.port=0` -and then inject the actual (``local'') port as a `@Value`. For example: +and then inject the actual ('`local`' ) port as a `@Value`. For example: [source,java,indent=0,subs="verbatim,quotes,attributes"] ---- @@ -835,45 +835,45 @@ added. `WebMvcAutoConfiguration` adds the following `ViewResolvers` to your context: -* An `InternalResourceViewResolver` with bean id ``defaultViewResolver''. This one locates +* An `InternalResourceViewResolver` with bean id '`defaultViewResolver`' . This one locates physical resources that can be rendered using the `DefaultServlet` (e.g. static resources and JSP pages if you are using those). It applies a prefix and a suffix to the view name and then looks for a physical resource with that path in the servlet context (defaults are both empty, but accessible for external configuration via `spring.view.prefix` and `spring.view.suffix`). It can be overridden by providing a bean of the same type. -* A `BeanNameViewResolver` with id ``beanNameViewResolver''. This is a useful member of the +* A `BeanNameViewResolver` with id '`beanNameViewResolver`' . This is a useful member of the view resolver chain and will pick up any beans with the same name as the `View` being resolved. It shouldn't be necessary to override or replace it. -* A `ContentNegotiatingViewResolver` with id ``viewResolver'' is only added if there *are* - actually beans of type `View` present. This is a ``master'' resolver, delegating to all - the others and attempting to find a match to the ``Accept'' HTTP header sent by the +* A `ContentNegotiatingViewResolver` with id '`viewResolver`' is only added if there *are* + actually beans of type `View` present. This is a '`master`' resolver, delegating to all + the others and attempting to find a match to the '`Accept`' HTTP header sent by the client. There is a useful https://spring.io/blog/2013/06/03/content-negotiation-using-views[blog about `ContentNegotiatingViewResolver`] that you might like to study to learn more, and also look at the source code for detail. You can switch off the auto-configured - `ContentNegotiatingViewResolver` by defining a bean named ``viewResolver''. + `ContentNegotiatingViewResolver` by defining a bean named '`viewResolver`' . * If you use Thymeleaf you will also have a `ThymeleafViewResolver` with id - ``thymeleafViewResolver''. It looks for resources by surrounding the view name with a + '`thymeleafViewResolver`' . It looks for resources by surrounding the view name with a prefix and suffix (externalized to `spring.thymeleaf.prefix` and - `spring.thymeleaf.suffix`, defaults ``classpath:/templates/'' and ``.html'' + `spring.thymeleaf.suffix`, defaults '`classpath:/templates/`' and '`.html`' respectively). It can be overridden by providing a bean of the same name. * If you use FreeMarker you will also have a `FreeMarkerViewResolver` with id - ``freeMarkerViewResolver''. It looks for resources in a loader path (externalized to - `spring.freemarker.templateLoaderPath`, default ``classpath:/templates/'') by + '`freeMarkerViewResolver`' . It looks for resources in a loader path (externalized to + `spring.freemarker.templateLoaderPath`, default '`classpath:/templates/`' ) by surrounding the view name with a prefix and suffix (externalized to `spring.freemarker.prefix` - and `spring.freemarker.suffix`, with empty and ``.ftl'' defaults respectively). It can + and `spring.freemarker.suffix`, with empty and '`.ftl`' defaults respectively). It can be overridden by providing a bean of the same name. * If you use Groovy templates (actually if groovy-templates is on your classpath) you will - also have a `Groovy TemplateViewResolver` with id ``groovyTemplateViewResolver''. It + also have a `Groovy TemplateViewResolver` with id '`groovyTemplateViewResolver`' . It looks for resources in a loader path by surrounding the view name with a prefix and suffix (externalized to `spring.groovy.template.prefix` and - `spring.groovy.template.suffix`, defaults ``classpath:/templates/'' and ``.tpl'' + `spring.groovy.template.suffix`, defaults '`classpath:/templates/`' and '`.tpl`' respectively). It can be overriden by providing a bean of the same name. -* If you use Velocity you will also have a `VelocityViewResolver` with id ``velocityViewResolver''. +* If you use Velocity you will also have a `VelocityViewResolver` with id '`velocityViewResolver`' . It looks for resources in a loader path (externalized to `spring.velocity.resourceLoaderPath`, - default ``classpath:/templates/'') by surrounding the view name with a prefix and suffix - (externalized to `spring.velocity.prefix` and `spring.velocity.suffix`, with empty and ``.vm'' + default '`classpath:/templates/`' ) by surrounding the view name with a prefix and suffix + (externalized to `spring.velocity.prefix` and `spring.velocity.suffix`, with empty and '`.vm`' defaults respectively). It can be overridden by providing a bean of the same name. Check out {sc-spring-boot-autoconfigure}/web/WebMvcAutoConfiguration.{sc-ext}[`WebMvcAutoConfiguration`], @@ -1032,7 +1032,7 @@ your own, and bind it to a set of `Environment` properties e.g. ---- See '<>' in the -``Spring Boot features'' section and the +'`Spring Boot features`' section and the {sc-spring-boot-autoconfigure}/jdbc/DataSourceAutoConfiguration.{sc-ext}[`DataSourceAutoConfiguration`] class for more details. @@ -1130,7 +1130,7 @@ for more details. [[howto-use-custom-entity-manager]] === Use a custom EntityManagerFactory To take full control of the configuration of the `EntityManagerFactory`, you need to add -a `@Bean` named ``entityManagerFactory''. Spring Boot auto-configuration switches off its +a `@Bean` named '`entityManagerFactory`' . Spring Boot auto-configuration switches off its entity manager based on the presence of a bean of that type. @@ -1185,7 +1185,7 @@ might be able to use a JTA transaction manager spanning both. Spring doesn't require the use of XML to configure the JPA provider, and Spring Boot assumes you want to take advantage of that feature. If you prefer to use `persistence.xml` then you need to define your own `@Bean` of type `LocalEntityManagerFactoryBean` (with -id ``entityManagerFactory'', and set the persistence unit name there. +id '`entityManagerFactory`' , and set the persistence unit name there. See https://github.com/spring-projects/spring-boot/blob/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration.java[`JpaBaseConfiguration`] @@ -1201,7 +1201,7 @@ automatically. If they are both present on the classpath, you might have to do s configuration to tell Spring Boot which one (or both) you want to create repositories for you. The most explicit way to do that is to use the standard Spring Data `@Enable*Repositories` and tell it the location of your `Repository` interfaces -(where ``*'' is ``Jpa'' or ``Mongo'' or both). +(where '`*`' is '`Jpa`' or '`Mongo`' or both). There are also flags `spring.data.*.repositories.enabled` that you can use to switch the auto-configured repositories on and off in external configuration. This is useful for @@ -1240,7 +1240,7 @@ values are `none`, `validate`, `update`, `create-drop`. Spring Boot chooses a de value for you based on whether it thinks your database is embedded (default `create-drop`) or not (default `none`). An embedded database is detected by looking at the `Connection` type: `hsqldb`, `h2` and `derby` are embedded, the rest are not. Be careful when switching -from in-memory to a ``real'' database that you don't make assumptions about the existence of +from in-memory to a '`real`' database that you don't make assumptions about the existence of the tables and data in the new platform. You either have to set `ddl-auto` explicitly, or use one of the other mechanisms to initialize the database. @@ -1266,7 +1266,7 @@ to start. The script locations can be changed by setting `spring.datasource.sche To disable the failfast you can set `spring.datasource.continueOnError=true`. This can be useful once an application has matured and been deployed a few times, since the scripts -can act as ``poor man's migrations'' -- inserts that fail mean that the data is already +can act as '`poor man's migrations`' -- inserts that fail mean that the data is already there, so there would be no need to prevent the application from running, for instance. If you want to use the `schema.sql` initialization in a JPA app (with @@ -1303,7 +1303,7 @@ To automatically run Flyway database migrations on startup, add the `org.flywaydb:flyway-core` to your classpath. The migrations are scripts in the form `V__.sql` (with `` an -underscore-separated version, e.g. ``1'' or ``2_1''). By default they live in a folder +underscore-separated version, e.g. '`1`' or '`2_1`' ). By default they live in a folder `classpath:db/migration` but you can modify that using `flyway.locations` (a list). See the Flyway class from flyway-core for details of available settings like schemas etc. In addition Spring Boot provides a small set of properties in @@ -1382,13 +1382,13 @@ For more detail look at the {sc-spring-boot-actuator}/autoconfigure/ManagementServerProperties.{sc-ext}[`ManagementServerProperties`] source code and '<>' -in the ``Production-ready features'' section. +in the '`Production-ready features`' section. [[howto-customize-the-whitelabel-error-page]] -=== Customize the ``whitelabel'' error page -Spring Boot installs a ``whitelabel'' error page that you will see in browser client if +=== Customize the '`whitelabel`' error page +Spring Boot installs a '`whitelabel`' error page that you will see in browser client if you encounter a server error (machine clients consuming JSON and other media types should see a sensible response with the right error code). To switch it off you can set `error.whitelabel.enabled=false`, but normally in addition or alternatively to that you @@ -1596,7 +1596,7 @@ To configure IntelliJ correctly you can use the `idea` Gradle plugin: NOTE: Intellij must be configured to use the same Java version as the command line Gradle task and `springloaded` *must* be included as a `buildscript` dependency. -You can also additionally enable ``Make Project Automatically'' inside Intellij to +You can also additionally enable '`Make Project Automatically`' inside Intellij to automatically compile your code whenever a file is saved. @@ -1634,7 +1634,7 @@ third-party dependencies. Overriding versions may cause compatibility issues. [[howto-create-an-executable-jar-with-maven]] === Create an executable JAR with Maven -The `spring-boot-maven-plugin` can be used to create an executable ``fat'' JAR. If you +The `spring-boot-maven-plugin` can be used to create an executable '`fat`' JAR. If you are using the `spring-boot-starter-parent` POM you can simply declare the plugin and your jars will be repackaged: @@ -1683,7 +1683,7 @@ If you want to use your project as a library jar for other projects to depend on addition have an executable (e.g. demo) version of it, you will want to configure the build in a slightly different way. -For Maven the normal JAR plugin and the Spring Boot plugin both have a ``classifier'' +For Maven the normal JAR plugin and the Spring Boot plugin both have a '`classifier`' configuration that you can add to create an additional JAR. Example (using the Spring Boot Starter Parent to manage the plugin versions and other configuration defaults): @@ -1703,7 +1703,7 @@ Boot Starter Parent to manage the plugin versions and other configuration defaul ---- Two jars are produced, the default one, and an executable one using the Boot plugin with -classifier ``exec''. +classifier '`exec`' . For Gradle users the steps are similar. Example: @@ -1724,7 +1724,7 @@ jar support which assumes that the `jruby-complete.jar` is always directly avail file in its own right. To deal with any problematic libraries, you can flag that specific nested jars should be -automatically unpacked to the ``temp folder'' when the executable jar first runs. +automatically unpacked to the '`temp folder`' when the executable jar first runs. For example, to indicate that JRuby should be flagged for unpack using the Maven Plugin you would add the following configuration: @@ -1881,7 +1881,7 @@ archive as normal. To make it executable: . Use the appropriate launcher as a `Main-Class`, e.g. `JarLauncher` for a jar file, and specify the other properties it needs as manifest entries, principally a `Start-Class`. -. Add the runtime dependencies in a nested ``lib'' directory (for a jar) and the +. Add the runtime dependencies in a nested '`lib`' directory (for a jar) and the `provided` (embedded container) dependencies in a nested `lib-provided` directory. Remember *not* to compress the entries in the archive. @@ -1934,13 +1934,13 @@ after which you can run the application with Use the `SpringBootServletInitializer` base class, which is picked up by Spring's Servlet 3.0 support on deployment. Add an extension of that to your project and build a war file as normal. For more detail, see the -http://spring.io/guides/gs/convert-jar-to-war[``Converting a jar Project to a war''] guide +http://spring.io/guides/gs/convert-jar-to-war['`Converting a jar Project to a war`' ] guide on the spring.io website and the sample below. The war file can also be executable if you use the Spring Boot build tools. In that case the embedded container classes (to launch Tomcat for instance) have to be added to the war in a `lib-provided` directory. The tools will take care of that as long as the -dependencies are marked as ``provided'' in Maven or Gradle. Here's a Maven example +dependencies are marked as '`provided`' in Maven or Gradle. Here's a Maven example {github-code}/spring-boot-samples/spring-boot-sample-traditional/pom.xml[in the Boot Samples]. diff --git a/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc b/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc index c0a214bacb..94e508a18d 100644 --- a/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc @@ -15,7 +15,7 @@ Auditing, health and metrics gathering can be automatically applied to your appl == Enabling production-ready features. The {github-code}/spring-boot-actuator[`spring-boot-actuator`] module provides all of Spring Boot's production-ready features. The simplest way to enable the features is to add -a dependency to the `spring-boot-starter-actuator` ``Starter POM''. +a dependency to the `spring-boot-starter-actuator` '`Starter POM`'. .Definition of Actuator **** @@ -24,7 +24,7 @@ controlling something. Actuators can generate a large amount of motion from a sm change. **** -To add the actuator to a Maven based project, add the following ``starter'' +To add the actuator to a Maven based project, add the following '`starter`' dependency: [source,xml,indent=0] @@ -66,7 +66,7 @@ The following endpoints are available: |`autoconfig` |Displays an auto-configuration report showing all auto-configuration candidates and the - reason why they ``were'' or ``were not'' applied. + reason why they '`were`' or '`were not`' applied. |true |`beans` @@ -86,7 +86,7 @@ The following endpoints are available: |true |`health` -|Shows application health information (defaulting to a simple ``OK'' message). +|Shows application health information (defaulting to a simple '`OK`' message). |false |`info` @@ -94,7 +94,7 @@ The following endpoints are available: |false |`metrics` -|Shows ``metrics'' information for the current application. +|Shows '`metrics`' information for the current application. |true |`mappings` @@ -138,7 +138,7 @@ that is being configured. [[production-ready-health]] === Custom health information -The default information exposed by the `health` endpoint is a simple ``OK'' message. It +The default information exposed by the `health` endpoint is a simple '`OK`' message. It is often useful to perform some additional health checks, for example you might check that a database connection works, or that a remote REST endpoint is functioning. @@ -220,7 +220,7 @@ filtering. In your `pom.xml` you have (inside the `` element): ---- -You can then refer to your Maven ``project properties'' via placeholders, e.g. +You can then refer to your Maven '`project properties`' via placeholders, e.g. [source,properties,indent=0] ---- @@ -299,12 +299,12 @@ all non-sensitive endpoints to be exposed over HTTP. The default convention is t [[production-ready-sensitive-endpoints]] === Exposing sensitive endpoints -If you use ``Spring Security'' sensitive endpoints will be exposed over HTTP, but also -protected. By default ``basic'' authentication will be used with the username `user` +If you use '`Spring Security`' sensitive endpoints will be exposed over HTTP, but also +protected. By default '`basic`' authentication will be used with the username `user` and a generated password (which is printed on the console when the application starts). -TIP: Generated passwords are logged as the application starts. Search for ``Using default -security password''. +TIP: Generated passwords are logged as the application starts. Search for '`Using default +security password`'. You can use Spring properties to change the username and password and to change the security role required to access the endpoints. For example, you might set the following @@ -480,7 +480,7 @@ If you are using Jolokia but you don't want Spring Boot to configure it, simply [[production-ready-remote-shell]] == Monitoring and management using a remote shell -Spring Boot supports an integrated Java shell called ``CRaSH''. You can use CRaSH to +Spring Boot supports an integrated Java shell called '`CRaSH`'. You can use CRaSH to `ssh` or `telnet` into your running application. To enable remote shell support add a dependency to `spring-boot-starter-remote-shell`: @@ -536,7 +536,7 @@ and `endpoint` commands. ==== Remote shell credentials You can use the `shell.auth.simple.user.name` and `shell.auth.simple.user.password` properties to configure custom connection credentials. It is also possible to use a -``Spring Security'' `AuthenticationManager` to handle login duties. See the +'`Spring Security`' `AuthenticationManager` to handle login duties. See the {dc-spring-boot-actuator}/autoconfigure/CrshAutoConfiguration.{dc-ext}[`CrshAutoConfiguration`] and {dc-spring-boot-actuator}/autoconfigure/ShellProperties.{dc-ext}[`ShellProperties`] Javadoc for full details. @@ -559,7 +559,7 @@ for details). By default Spring Boot will search for commands in the following l TIP: You can change the search path by settings a `shell.commandPathPatterns` property. -Here is a simple ``hello world'' command that could be loaded from +Here is a simple '`hello world`' command that could be loaded from `src/main/resources/commands/hello.groovy` [source,groovy,indent=0] @@ -615,8 +615,8 @@ documentation]. [[production-ready-metrics]] == Metrics -Spring Boot Actuator includes a metrics service with ``gauge'' and ``counter'' support. -A ``gauge'' records a single value; and a ``counter'' records a delta (an increment or +Spring Boot Actuator includes a metrics service with '`gauge`' and '`counter`' support. +A '`gauge`' records a single value; and a '`counter`' records a delta (an increment or decrement). Spring Boot Actuator also provides a {sc-spring-boot-actuator}/endpoint/PublicMetrics.{sc-ext}[`PublicMetrics`] interface that you can implement to expose metrics that you cannot record via one of those two @@ -657,7 +657,7 @@ endpoint you should see a response similar to this: ---- Here we can see basic `memory`, `heap`, `class loading`, `processor` and `thread pool` -information along with some HTTP metrics. In this instance the `root` (``/'') and `/metrics` +information along with some HTTP metrics. In this instance the `root` ('`/`') and `/metrics` URLs have returned `HTTP 200` responses `20` and `3` times respectively. It also appears that the `root` URL returned `HTTP 401` (unauthorized) `4` times. The double asterix (`star-star`) comes from a request matched by Spring MVC as `/**` (normally a static resource). @@ -768,22 +768,22 @@ an `Exporter` interface and a few basic implementations for you to get started w [[production-ready-code-hale-metrics]] === Coda Hale Metrics -User of the http://metrics.codahale.com/[Coda Hale ``Metrics'' library] will automatically +User of the http://metrics.codahale.com/[Coda Hale '`Metrics`' library] will automatically find that Spring Boot metrics are published to `com.codahale.metrics.MetricRegistry`. A default `com.codahale.metrics.MetricRegistry` Spring bean will be created when you declare a dependency to the `com.codahale.metrics:metrics-core` library; you can also register you own `@Bean` instance if you need customizations. Users can create Coda Hale metrics by prefixing their metric names with the appropriate -type (e.g. `histogram.*`, `meter.*`). +type (e.g. `histogram.\*`, `meter.\*`). [[production-ready-metrics-message-channel-integration]] === Message channel integration -If the ``Spring Messaging'' jar is on your classpath a `MessageChannel` called +If the '`Spring Messaging`' jar is on your classpath a `MessageChannel` called `metricsChannel` is automatically created (unless one already exists). All metric update -events are additionally published as ``messages'' on that channel. Additional analysis or +events are additionally published as '`messages`' on that channel. Additional analysis or actions can be taken by clients subscribing to that channel. @@ -791,7 +791,7 @@ actions can be taken by clients subscribing to that channel. [[production-ready-auditing]] == Auditing Spring Boot Actuator has a flexible audit framework that will publish events once Spring -Security is in play (``authentication success'', ``failure'' and ``access denied'' +Security is in play ('`authentication success`', '`failure`' and '`access denied`' exceptions by default). This can be very useful for reporting, and also to implement a lock-out policy based on authentication failures. @@ -898,6 +898,6 @@ look at the actuator {github-code}/spring-boot-samples[sample applications]. You might want to read about graphing tools such as http://graphite.wikidot.com/[Graphite]. Otherwise, you can continue on, to read about <> or jump ahead +'`cloud deployment options`'>> or jump ahead for some in depth information about Spring Boot's '<>'. diff --git a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index cf64672e46..30be4553b5 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -83,7 +83,7 @@ For a complete list of the configuration options, see the [[boot-features-fluent-builder-api]] === Fluent builder API If you need to build an `ApplicationContext` hierarchy (multiple contexts with a -parent/child relationship), or if you just prefer using a ``fluent'' builder API, you +parent/child relationship), or if you just prefer using a '`fluent`' builder API, you can use the `SpringApplicationBuilder`. The `SpringApplicationBuilder` allows you to chain together multiple method calls, and @@ -139,7 +139,7 @@ your behalf. By default, an `AnnotationConfigApplicationContext` or `AnnotationConfigEmbeddedWebApplicationContext` will be used, depending on whether you are developing a web application or not. -The algorithm used to determine a ``web environment'' is fairly simplistic (based on the +The algorithm used to determine a '`web environment`' is fairly simplistic (based on the presence of a few classes). You can use `setWebEnvironment(boolean webEnvironment)` if you need to override the default. @@ -259,7 +259,7 @@ value and `max` is the maximum (exclusive). [[boot-features-external-config-command-line-args]] === Accessing command line properties By default `SpringApplication` will convert any command line option arguments (starting -with ``--'', e.g. `--server.port=9000`) to a `property` and add it to the Spring +with '`--`', e.g. `--server.port=9000`) to a `property` and add it to the Spring `Environment`. As mentioned above, command line properties always take precedence over other property sources. @@ -340,7 +340,7 @@ properties). app.description=${app.name} is a Spring Boot application ---- -TIP: You can also use this technique to create ``short'' variants of existing Spring Boot +TIP: You can also use this technique to create '`short`' variants of existing Spring Boot properties. See the '<>' how-to for details. @@ -353,7 +353,7 @@ for specifying hierarchical configuration data. The `SpringApplication` class wi automatically support YAML as an alternative to properties whenever you have the http://code.google.com/p/snakeyaml/[SnakeYAML] library on your classpath. -NOTE: If you use ``starter POMs'' SnakeYAML will be automatically provided via +NOTE: If you use '`starter POMs`' SnakeYAML will be automatically provided via `spring-boot-starter`. @@ -675,7 +675,7 @@ http://logging.apache.org/log4j/[Log4J] and http://logback.qos.ch/[Logback]. In each case there is console output and file output (rotating, 10 Mb file size). -By default, if you use the ``Starter POMs'', Logback will be used for logging. Appropriate +By default, If you use the '`Starter POMs`', Logback will be used for logging. Appropriate Logback routing is also included to ensure that dependent libraries that use Java Util Logging, Commons Logging, Log4J or SLF4J will all work correctly. @@ -740,8 +740,8 @@ As with console output, `ERROR`, `WARN` and `INFO` level messages are logged by === Log Levels All the supported logging systems can have the logger levels set in the Spring -`Environment` (so for example in `application.properties`) using ``logging.level.*=LEVEL'' -where ``LEVEL'' is one of TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF. Example +`Environment` (so for example in `application.properties`) using '`logging.level.*=LEVEL`' +where '`LEVEL`' is one of TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF. Example `application.properties`: [source,properties,indent=0,subs="verbatim,quotes,attributes"] @@ -801,8 +801,8 @@ To help with the customization some other properties are transferred from the Sp All the logging systems supported can consult System properties when parsing their configuration files. See the default configurations in `spring-boot.jar` for examples. -WARNING: There are known classloading issues with Java Util Logging that cause problems -when running from an ``executable jar''. We recommend that you avoid it if at all +WARNING: There are know classloading issues with Java Util Logging that cause problems +when running from an '`executable jar`'. We recommend that you avoid it if at all possible. @@ -820,9 +820,9 @@ If you haven't yet developed a Spring Boot web application you can follow the [[boot-features-spring-mvc]] -=== The ``Spring Web MVC framework'' -The Spring Web MVC framework (often referred to as simply ``Spring MVC'') is a rich -``model view controller'' web framework. Spring MVC lets you create special `@Controller` +=== The '`Spring Web MVC framework`' +The Spring Web MVC framework (often referred to as simply '`Spring MVC`') is a rich +'`model view controller`' web framework. Spring MVC lets you create special `@Controller` or `@RestController` beans to handle incoming HTTP requests. Methods in your controller are mapped to HTTP using `@RequestMapping` annotations. @@ -932,7 +932,7 @@ Spring decides not to handle it. Most of the time this will not happen (unless y the default MVC configuration) because Spring will always be able to handle requests through the `DispatcherServlet`. -In addition to the ``standard'' static resource locations above, a special case is made for +In addition to the '`standard`' static resource locations above, a special case is made for http://www.webjars.org/[Webjars content]. Any resources with a path in `/webjars/**` will be served from jar files if they are packaged in the Webjars format. @@ -968,11 +968,11 @@ servlet containers. [[boot-features-error-handling]] ==== Error Handling Spring Boot provides an `/error` mapping by default that handles all errors in a -sensible way, and it is registered as a ``global'' error page in the servlet container. +sensible way, and it is registered as a '`global`' error page in the servlet container. For machine clients it will produce a JSON response with details of the error, the HTTP -status and the exception message. For browser clients there is a ``whitelabel'' error +status and the exception message. For browser clients there is a '`whitelabel`' error view that renders the same data in HTML format (to customize it just add a `View` that -resolves to ``error''). To replace the default behaviour completely you can implement +resolves to '`error`'). To replace the default behaviour completely you can implement `ErrorController` and register a bean definition of that type, or simply add a bean of type `ErrorAttributes` to use the existing mechanism but replace the contents. @@ -1074,7 +1074,7 @@ All the registered endpoints should be `@Components` with HTTP resource annotati Since the `Endpoint` is a Spring `@Component` its lifecycle is managed by Spring and you can `@Autowired` dependencies and inject external configuration with `@Value`. The Jersey -servlet will be registered and mapped to ``/\*'' by default. You can change the mapping +servlet will be registered and mapped to '`/\*`' by default. You can change the mapping by adding `@ApplicationPath` to your `ResourceConfig`. There is a {github-code}/spring-boot-samples/spring-boot-sample-jersey[Jersey sample] so @@ -1088,7 +1088,7 @@ asks for them to be scanned in its `Filter` registration. [[boot-features-embedded-container]] === Embedded servlet container support Spring Boot includes support for embedded Tomcat and Jetty servers. Most developers will -simply use the appropriate ``Starter POM'' to obtain a fully configured instance. By +simply use the appropriate '`Starter POM`' to obtain a fully configured instance. By default both Tomcat and Jetty will listen for HTTP requests on port `8080`. @@ -1186,7 +1186,7 @@ yourself. ---- Setters are provided for many configuration options. Several protected method -``hooks'' are also provided should you need to do something more exotic. See the +'`hooks`' are also provided should you need to do something more exotic. See the source code documentation for details. @@ -1210,12 +1210,12 @@ you can see how to set things up. [[boot-features-security]] == Security If Spring Security is on the classpath then web applications will be secure by default -with ``basic'' authentication on all HTTP endpoints. To add method-level security to a web +with '`basic`' authentication on all HTTP endpoints. To add method-level security to a web application you can also add `@EnableGlobalMethodSecurity` with your desired settings. Additional information can be found in the {spring-security-reference}#jc-method[Spring Security Reference]. -The default `AuthenticationManager` has a single user (``user'' username and random +The default `AuthenticationManager` has a single user ('`user`' username and random password, printed at INFO level when the application starts up) [indent=0] @@ -1242,8 +1242,8 @@ The basic features you get out of the box in a web application are: * An `AuthenticationManager` bean with in-memory store and a single user (see `SecurityProperties.User` for the properties of the user). -* Ignored (unsecure) paths for common static resource locations (`/css/**`, `/js/**`, - `/images/**` and `**/favicon.ico`). +* Ignored (unsecure) paths for common static resource locations (`/css/\*\*`, `/js/\*\*`, + `/images/\*\*` and `\*\*/favicon.ico`). * HTTP Basic security for all other endpoints. * Security events published to Spring's `ApplicationEventPublisher` (successful and unsuccessful authentication and access denied). @@ -1274,7 +1274,7 @@ if you _do_ want to override the actuator access rules. [[boot-features-sql]] == Working with SQL databases The Spring Framework provides extensive support for working with SQL databases. From -direct JDBC access using `JdbcTemplate` to complete ``object relational mapping'' +direct JDBC access using `JdbcTemplate` to complete '`object relational mapping`' technologies such as Hibernate. Spring Data provides an additional level of functionality, creating `Repository` implementations directly from interfaces and using conventions to generate queries from your method names. @@ -1296,7 +1296,7 @@ Obviously, in-memory databases do not provide persistent storage; you will need populate your database when your application starts and be prepared to throw away data when your application ends. -TIP: The ``How-to'' section includes a '<>' Spring Boot can auto-configure embedded http://www.h2database.com[H2], @@ -1337,13 +1337,13 @@ Production database connections can also be auto-configured using a pooling * Lastly, if Commons DBCP2 is available we will use it If you use the `spring-boot-starter-jdbc` or `spring-boot-starter-data-jpa` -``starter POMs'' you will automatically get a dependency to `tomcat-jdbc`. +'`starter POMs`' you will automcatically get a dependency to `tomcat-jdbc`. NOTE: Additional connection pools can always be configured manually. If you define your own `DataSource` bean, auto-configuration will not occur. DataSource configuration is controlled by external configuration properties in -`spring.datasource.*`. For example, you might declare the following section +`spring.datasource.\*`. For example, you might declare the following section in `application.properties`: [source,properties,indent=0] @@ -1415,8 +1415,8 @@ you can `@Autowire` them directly into your own beans: [[boot-features-jpa-and-spring-data]] -=== JPA and ``Spring Data'' -The Java Persistence API is a standard technology that allows you to ``map'' objects to +=== JPA and '`Spring Data`' +The Java Persistence API is a standard technology that allows you to '`map`' objects to relational databases. The `spring-boot-starter-data-jpa` POM provides a quick way to get started. It provides the following key dependencies: @@ -1425,7 +1425,7 @@ started. It provides the following key dependencies: * Spring ORMs -- Core ORM support from the Spring Framework. TIP: We won't go into too many details of JPA or Spring Data here. You can follow the -http://spring.io/guides/gs/accessing-data-jpa/[``Accessing Data with JPA''] guide from +http://spring.io/guides/gs/accessing-data-jpa/['`Accessing Data with JPA`'] guide from http://spring.io and read the http://projects.spring.io/spring-data-jpa/[Spring Data JPA] and http://hibernate.org/orm/documentation/[Hibernate] reference documentation. @@ -1433,8 +1433,8 @@ and http://hibernate.org/orm/documentation/[Hibernate] reference documentation. [[boot-features-entity-classes]] ==== Entity Classes -Traditionally, JPA ``Entity'' classes are specified in a `persistence.xml` file. With -Spring Boot this file is not necessary and instead ``Entity Scanning'' is used. By +Traditionally, JPA '`Entity`' classes are specified in a `persistence.xml` file. With +Spring Boot this file is not necessary and instead '`Entity Scanning`' is used. By default all packages below your main configuration class (the one annotated with `@EnableAutoConfiguration`) will be searched. @@ -1586,7 +1586,7 @@ http://redis.io/[Redis] is a cache, message broker and richly-featured key-value Spring Boot offers basic auto-configuration for the https://github.com/xetorthio/jedis/[Jedis] client library and abstractions on top of it provided by https://github.com/spring-projects/spring-data-redis[Spring Data Redis]. There is a -`spring-boot-starter-redis` ``Starter POM'' for collecting the dependencies in a +`spring-boot-starter-redis` '`Starter POM`' for collecting the dependencies in a convenient way. @@ -1616,7 +1616,7 @@ instance will attempt to connect to a Redis server using `localhost:6379`: If you add a `@Bean` of your own of any of the auto-configured types it will replace the default (except in the case of `RedisTemplate` the exclusion is based on the bean name -``redisTemplate'' not its type). If `commons-pool2` is on the classpath you will get a +'`redisTemplate`' not its type). If `commons-pool2` is on the classpath you will get a pooled connection factory by default. @@ -1626,7 +1626,7 @@ pooled connection factory by default. http://www.mongodb.com/[MongoDB] is an open-source NoSQL document database that uses a JSON-like schema instead of traditional table-based relational data. Spring Boot offers several conveniences for working with MongoDB, including the The -`spring-boot-starter-data-mongodb` ``Starter POM''. +`spring-boot-starter-data-mongodb` '`Starter POM`'. @@ -1741,7 +1741,7 @@ documentation]. === Gemfire https://github.com/spring-projects/spring-data-gemfire[Spring Data Gemfire] provides convenient Spring-friendly tools for accessing the http://www.gopivotal.com/big-data/pivotal-gemfire#details[Pivotal Gemfire] -data management platform. There is a `spring-boot-starter-data-gemfire` ``Starter POM'' +data management platform. There is a `spring-boot-starter-data-gemfire` '`Starter POM`' for collecting the dependencies in a convenient way. There is currently no auto=config support for Gemfire, but you can enable Spring Data Repositories with a https://github.com/spring-projects/spring-data-gemfire/blob/master/src/main/java/org/springframework/data/gemfire/repository/config/EnableGemfireRepositories.java[single annotation]. @@ -1753,7 +1753,7 @@ https://github.com/spring-projects/spring-data-gemfire/blob/master/src/main/java http://lucene.apache.org/solr/[Apache Solr] is a search engine. Spring Boot offers basic auto-configuration for the solr client library and abstractions on top of it provided by https://github.com/spring-projects/spring-data-solr[Spring Data Solr]. There is -a `spring-boot-starter-data-solr` ``Starter POM'' for collecting the dependencies in a +a `spring-boot-starter-data-solr` '`Starter POM`' for collecting the dependencies in a convenient way. @@ -1806,7 +1806,7 @@ http://www.elasticsearch.org/[Elastic Search] is an open source, distributed, real-time search and analytics engine. Spring Boot offers basic auto-configuration for the Elasticsearch and abstractions on top of it provided by https://github.com/spring-projects/spring-data-elasticsearch[Spring Data Elasticsearch]. -There is a `spring-boot-starter-data-elasticsearch` ``Starter POM'' for collecting the +There is a `spring-boot-starter-data-elasticsearch` '`Starter POM`' for collecting the dependencies in a convenient way. @@ -1817,7 +1817,7 @@ You can inject an auto-configured `ElasticsearchTemplate` or Elasticsearch `Clie instance as you would any other Spring Bean. By default the instance will attempt to connect to a local in-memory server (a `NodeClient` in Elasticsearch terms), but you can switch to a remote server (i.e. a `TransportClient`) by setting -`spring.data.elasticsearch.clusterNodes` to a comma-separated ``host:port'' list. +`spring.data.elasticsearch.clusterNodes` to a comma-separated '`host:port`' list. [source,java,indent=0] ---- @@ -1862,7 +1862,7 @@ http://docs.spring.io/spring-data/elasticsearch/docs/[reference documentation]. The Spring Framework provides extensive support for integrating with messaging systems: from simplified use of the JMS API using `JmsTemplate` to a complete infrastructure to receive messages asynchronously. Spring AMQP provides a similar feature set for the -``Advanced Message Queuing Protocol'' and Boot also provides auto-configuration options +'`Advanced Message Queuing Protocol`' and Boot also provides auto-configuration options for `RabbitTemplate` and RabbitMQ. There is also support for STOMP messaging natively in Spring Websocket and Spring Boot has support for that through starters and a small amount of auto configuration. @@ -1919,7 +1919,7 @@ See {sc-spring-boot-autoconfigure}/jms/hornetq/HornetQProperties.{sc-ext}[`Horne for more of the supported options. No JNDI lookup is involved at all and destinations are resolved against their names, -either using the ``name'' attribute in the HornetQ configuration or the names provided +either using the '`name`' attribute in the HornetQ configuration or the names provided through configuration. @@ -2133,7 +2133,7 @@ provide good examples of how to write XA wrappers. Spring Integration provides abstractions over messaging and also other transports such as HTTP, TCP etc. If Spring Integration is available on your classpath it will be initialized through the `@EnableIntegration` annotation. Message processing statistics will be -published over JMX if ``spring-integration-jmx'' is also on the classpath. +published over JMX if `'spring-integration-jmx'` is also on the classpath. See the {sc-spring-boot-autoconfigure}/integration/IntegrationAutoConfiguration.{sc-ext}[`IntegrationAutoConfiguration`] class for more details. @@ -2143,7 +2143,7 @@ class for more details. == Monitoring and management over JMX Java Management Extensions (JMX) provide a standard mechanism to monitor and manage applications. By default Spring Boot will create an `MBeanServer` with bean id -``mbeanServer'' and expose any of your beans that are annotated with Spring JMX +'`mbeanServer`' and expose any of your beans that are annotated with Spring JMX annotations (`@ManagedResource`, `@ManagedAttribute`, `@ManagedOperation`). See the {sc-spring-boot-autoconfigure}/jmx/JmxAutoConfiguration.{sc-ext}[`JmxAutoConfiguration`] @@ -2163,7 +2163,7 @@ under the `org.springframework.boot.test` package. [[boot-features-test-scope-dependencies]] === Test scope dependencies If you use the -`spring-boot-starter-test` ``Starter POM'' (in the `test` `scope`), you will find +`spring-boot-starter-test` '`Starter POM`' (in the `test` `scope`), you will find the following provided libraries: * Spring Test -- integration test support for Spring applications. @@ -2182,14 +2182,14 @@ One of the major advantages of dependency injection is that it should make your easier to unit test. You can simply instantiate objects using the `new` operator without even involving Spring. You can also use _mock objects_ instead of real dependencies. -Often you need to move beyond ``unit testing'' and start ``integration testing'' (with +Often you need to move beyond '`unit testing`' and start '`integration testing`' (with a Spring `ApplicationContext` actually involved in the process). It's useful to be able to perform integration testing without requiring deployment of your application or needing to connect to other infrastructure. The Spring Framework includes a dedicated test module for just such integration testing. You can declare a dependency directly to `org.springframework:spring-test` or use the -`spring-boot-starter-test` ``Starter POM'' to pull it in transitively. +`spring-boot-starter-test` '`Starter POM`' to pull it in transitively. If you have not used the `spring-test` module before you should start by reading the {spring-reference}/#testing[relevant section] of the Spring Framework reference @@ -2449,7 +2449,7 @@ if you provide web specific configuration, your class may need to be applied aft === Condition annotations You almost always want to include one or more `@Condition` annotations on your auto-configuration class. The `@ConditionalOnMissingBean` is one common example that is -used to allow developers to ``override'' auto-configuration if they are not happy with +used to allow developers to '`override`' auto-configuration if they are not happy with your defaults. Spring Boot includes a number of `@Conditional` annotations that you can reuse in your own diff --git a/spring-boot-docs/src/main/asciidoc/using-spring-boot.adoc b/spring-boot-docs/src/main/asciidoc/using-spring-boot.adoc index 099adebccc..a71af63750 100644 --- a/spring-boot-docs/src/main/asciidoc/using-spring-boot.adoc +++ b/spring-boot-docs/src/main/asciidoc/using-spring-boot.adoc @@ -1,3 +1,4 @@ + [[using-boot]] = Using Spring Boot @@ -198,7 +199,7 @@ running quickly and with a consistent, supported set of managed transitive depen .What's in a name **** -All starters follow a similar naming pattern; `spring-boot-starter-*`, where `*` is +All starters follow a similar naming pattern; `spring-boot-starter-\*`, where `*` is a particular type of application. This naming structure is intended to help when you need to find a starter. The Maven integration in many IDEs allow you to search dependencies by name. For example, with the appropriate Eclipse or STS plugin installed, you can simply