== Upgrading from Spring Boot 1.1

=== Servlet 3.1, Tomcat 8 and Jetty 9
Spring Boot now uses Tomcat 8 and Jetty 9 as embedded servlet containers. This provides Servlet 3.1 and enhanced WebSocket support out of the box. You can still use Tomcat 7 or Jetty 8 if you prefer to stick to an older version. See the https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-tomcat7-jsp[`spring-boot-sample-tomcat7-jsp`] and https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-jetty8[`spring-boot-sample-jetty8`] samples for downgrade examples.

=== Logging output
The default logging configuration has been updated with Spring Boot 1.2 to no longer write log files. If you want file output, you can use the `logging.path` or `logging.file` properties. You can still also completely customize logging by adding your own `logback.xml` file.

=== Consistent HTTP URI/body decoding
A `CharacterEncodingFilter` is now registered automatically for consistent URI/body decoding. You can use the `spring.http.encoding.charset` property if you need something other than `UTF-8` or set `spring.http.encoding.enabled` to false if you don't want the `CharacterEncodingFilter` registered at all.

=== IgnoreDefaultModelOnRedirect with Spring MVC
Spring MVC auto-configuration now sets the `ignoreDefaultModelOnRedirect` property of `RequestMappingHandlerAdapter` to `true` by default. If you need model attributes to be part of your redirect URLs you can add the following to your `application.properties`:

```
spring.mvc.ignore-default-model-on-redirect=false
```

=== Jackson defaults
The auto-configured Jackson `ObjectMapper` now has `MapperFeature.DEFAULT_VIEW_INCLUSION` and
`DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES` disabled. If you need to revert to the previous settings you can add the following to your `application.properties`:

```
spring.jackson.mapper.default-view-inclusion=true
spring.jackson.deserialization.fail-on-unknown-properties=true
```

=== Mongo and MongoDbFactory Beans
The `MongoAutoConfiguration` class will no longer register a `Mongo` bean if you define your own `MongoDbFactory` bean. Ensure that you either register a `Mongo` bean whenever you declare your own `MongoDbFactory` bean, or that you only use the `MongoDbFactory` interface to access Mongo databases.

=== Moved health.* properties to management.health.*

Health-related configuration keys have been moved from `health` to `management.health` for consistency with other management-related properties.

=== Renamed VanillaHealthIndicator class
The `VanillaHealthIndicator` class has been renamed to `ApplicationHealthIndicator`. Most users will not interact with the class directly, however, if you previously imported `org.springframework.boot.actuate.health.VanillaHealthIndicator` in your code you will need to change it to `org.springframework.boot.actuate.health.ApplicationHealthIndicator`.

=== Hibernate
The `SpringNamingStrategy` class has been moved to the `org.springframework.boot.orm.jpa.hibernate` package. The old `org.springframework.boot.orm.jpa.SpringNamingStrategy` remains but is deprecated and will be removed in a future release.

Managed dependencies are now provided for `hibernate-envers`, `hibernate-jpamodelgen` and `hibernate-ehcache`.

==== PersistenceExceptionTranslationPostProcessor
A `PersistenceExceptionTranslationPostProcessor` will now be registered by default. If you don't want exception translation set the `spring.dao.exceptiontranslation.enabled` property to `false`.

=== Health JSON
The `/health` actuator endpoint JSON has been slightly modified when only a single `HealthIndicator` is involved. You might need to update any monitoring tools if you previously queried a specific JSON path.

=== Anonymous health access restrictions
The `/health` actuator endpoint now restricts anonymous access. When accessed anonymously the endpoint hides the health details and simply indicates if the server is `UP` or `DOWN`. It also caches the response for the period
specified by `endpoints.health.time-to-live`. These restrictions can be disabled, thereby restoring 1.1.x's behavior, by setting `endpoints.health.sensitive` to `false`.

=== Spring 4.1
Spring Boot 1.2 requires Spring Framework 4.1.5 or later and is not compatible with Spring Framework 4.0.

=== Hikari CP
The version of `com.zaxxer:HikariCP` that's provide by Boot's dependency management now requires Java 8. If you're running on Java 6 or Java 7 you should update your dependency to use `com.zaxxer:HikariCP-java6` instead.

=== Configuration Properties
The property `spring.data.mongo.repositories.enabled` has been renamed to `spring.data.mongodb.repositories.enabled`.

=== Deprecations
* The `org.springframework.boot.actuate.system.ApplicationPidListener` class has been superseded by `ApplicationPidFileWriter`
* The CLI `@EnableRabbitMessaging` annotation has been superseded by `@EnableRabbit` from the `spring-rabbit` project.
* The `http.mappers.*` properties are deprecated in favor of their `spring.jackson.serialization.*` equivalents.
* `org.springframework.boot.json.SimpleJsonParser` has been deprecated in favor of `BasicJsonParser` to avoid confusion with the ``JSON Simple'' library.

== New and Noteworthy

=== Version Updates
Spring Boot 1.2 builds on and requires Spring Framework 4.1. Several 3rd party dependencies have been upgraded with this release including Jackson, Joda Time and Hibernate Validator. Tomcat 8 and Jetty 9 are now the default embedded servlet containers (providing Servlet 3.1 support).

=== @SpringBootApplication annotation
A new `@SpringBootApplication` convenience annotation has been added which is equivalent to `@Configuration` + `@EnableAutoConfiguration` + `@ComponentScan`. If you find you use frequently use those three annotations, you might want to consider swapping.

=== JTA Support
Spring Boot 1.2 now supports distributed JTA transactions across multiple XA resources using either an Atomkos or Bitronix embedded transaction manager. JTA transactions are also supported when deploying to a suitable Java EE Application Server.

When a JTA environment is detected, Spring's `JtaTransactionManager` will be used to manage transactions. Auto-configured JMS, DataSource and JPA beans will be upgraded to support XA transactions. You can use standard Spring idioms such as `@Transactional` to participate in a distributed transaction.

Additionally, general support classes are provided to make Atomkos and Bitronix easier to configure, even if you are not using `@EnableAutoConfiguration`. See the https://docs.spring.io/spring-boot/docs/1.2.x/reference/htmlsingle/#boot-features-jta[JTA section] of the reference manual for details.

=== JNDI Lookups
If you are using a full Java EE Application Server you can now lookup both `DataSource` and JMS `ConnectionFactory` beans from JNDI. Use the `spring.datasource.jndi-name` and `spring.jms.jndi-name` properties in your `application.properties` or `application.yml` file.

=== Jackson customization
It is now possible to https://docs.spring.io/spring-boot/docs/1.2.x/reference/htmlsingle/#howto-customize-the-jackson-objectmapper[customize the Jackson `ObjectMapper`] using `spring.jackson` properties. Jackson's `SerializationFeature`, `DeserializationFeature`, `MapperFeature`, `JsonParser.Feature` and `JsonGenerator.Feature` objects can be customized using `serialization`, `deserialization`, `mapper`, `parser` and `generator` properties. For example to enable `DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES` you could add the following to your `application.properties`:

```
spring.jackson.deserialization.fail-on-unknown-properties=true
```

Additionally `spring.jackson.date-format` and `spring.jackson.property-naming-strategy` properties have also been added with Spring Boot 1.2.

=== Banner Interface
A new `Banner` interface has been added which can be used in combination with `SpringApplication.setBanner(...)` to provide customized banner output. The use of `src/main/resources/banner.txt` is still recommended for simple banners, however, the new interface is useful if you need to do something fancy.

=== Banner Properties
You can now use `${application.version}`, `${spring-boot.version}`, `${application.formatted-version}` and `${spring-boot.formatted-version}` variables in your `src/main/resources/banner.txt` file to print your application version and/or the version of Spring Boot. The `formatted-version` is enclosed in brackets and includes a `v` prefix, for example, `(v1.2.0.RELEASE)`.

=== JMS Support
Auto-configuration is now provided for Spring Framework 4.1's `@JmsListener` annotation. The `@EnableJms` annotation is also auto-configured whenever you have `spring-jms.jar` on your classpath.

=== AMQP Support
Similarly, auto-configuration is now provided for Spring AMQP 1.4's `@RabbitListener` annotation. The `@EnableRabbit` annotation is also auto-configured whenever you have `spring-rabbit.jar` on your classpath. The existing Rabbit auto-configuration has also been extended to automatically create a `RabbitMessagingTemplate`.

=== Spring Cloud Connectors
Auto-configuration has been added for `spring-cloud-connectors` and a new `spring-boot-starter-cloud-connectors` POM has also been included with this release. Auto-configuration provides equivalent functionality to the `@CloudScan` annotation.

=== Email Support
A new `spring-boot-starter-mail` ``starter POM'' has been added along with auto-configuration support. You can inject a `JavaMailSender` bean into your services to https://docs.spring.io/spring-boot/docs/1.2.x/reference/htmlsingle/#boot-features-email[send emails]. The `spring.mail.*` properties can be used to customize items such as the SMTP host.

=== Undertow Embedded Servlet Container
In addition to Tomcat and Jetty, Spring Boot now supports https://undertow.io[Undertow] as an embedded Servlet container. See the reference documentation for details of how to switch.

=== CLI Updates
==== Creating a new project
The `spring` CLI command line tool includes a new `init` option which can be used to create a project from https://start.spring.io[start.spring.io]. For example, to create a new web application you can type:

```
$ spring init -d=web myapp.zip
```

==== CLI extensions
CLI extensions can now be installed and uninstalled using the CLI itself. The `spring install <maven coordinates>` will grab a remote jar and install it into the CLI. `spring uninstall` can be used to remove a previously installed extension.

==== Other CLI changes
The CLI now detects and support Spring's `@Cacheable` annotation.

=== Declarative SSL with Jetty and Tomcat
SSL can now be https://docs.spring.io/spring-boot/docs/1.2.x/reference/htmlsingle/#howto-configure-ssl[configured declaratively] by setting the various `server.ssl.*` properties. Support is provided for both Tomcat and Jetty. See the reference documentation for more details.

=== Actuator Endpoints
A global `endpoints.enabled` property has been added to configure if endpoints should be enabled or disabled by default. This allows you to witch from the current ``opt-out'' model to an ``opt-in'' model. For example, to disable all endpoints _except_ `health` you can use the following `application.properties`:

```
endpoints.enabled=false
endpoints.health.enabled=true
```

=== Metrics
==== System metrics
System metrics are now provided for heap, thread, class and GC information.

==== DataSource metrics
DataSource pool metrics are now exposed via the `/metrics` actuator endpoint. The number of active connections and pool usage details are exposed for Tomcat, Hikari and Commons DBCP connection pools.

==== Tomcat session metrics
If you are using Tomcat as your embedded servlet container metrics are now exposed for the number of active and maximum sessions.

==== Dropwizard metrics
Items from Dropwizard's `MetricRegistry` are now automatically exposed via the `/metrics` endpoint. Gauges and Counters are reflected as a single value. Timers, Meters and Histograms are expanded into sets of metrics containing all the properties of type Number.

=== Health indicators
==== JSON format
The `/health` actuator endpoint now returns consistent JSON regardless of the number of `HealthIndicators` actually involved. This makes it much easier to query the JSON for a specific item.

==== DataSourceHealthIndicator
`DataSourceHealthIndicator` now uses the `spring.datasource.validation-query` property (if it has been set) to check the health of the database.

==== DiskSpaceHealthIndicator
Free disk space is now reported as part or the `/health` indicator and will be used trigger a `DOWN` status if it drops below a certain threshold (by default 10Mb). The `health.diskspace.path` and `health.diskspace.threshold` properties can be used to customize the indicator.

=== Conditions
The `@ConditionalOnProperty` annotation has been updated with new `havingValue` and `matchIfMissing` attributes. You can now use the condition to create much more complex property matching conditions. A new `AnyNestedCondition` class has also been added which can be used to compose other `@Conditions`. Finally, the `@ConditionalOnBean` annotation now supports types declared as a String attribute as well as a `Class`.

=== GSON Support
It is now possible to use GSON instead of Jackson to create JSON output. Jackson remains the default and recommended choice. If you use GSON you should exclude Jackson libraries from your Maven/Gradle build unless your are using Spring Boot's Actuator which requires Jackson. As of Spring Boot 1.2.2, if both Gson and Jackson are on the classpath, you can configure your application to use Gson by setting `spring.http.converters.preferred-json-mapper` to `gson`.

=== EmbeddedServerPortWriter
The `spring-actuator` project includes a new `org.springframework.boot.actuate.system.EmbeddedServerPortFileWriter` class which can be used to write the port number of the embedded server to file when the application starts up.

=== Log4j2
Log4J is now supported as an alternative logging system and `spring-boot-starter-log4j2` start POM is provided. Logback remains the default and recommended logging system.

=== Jersey auto-configuration
Auto-configuration support is now provided for Jersey. Refer to reference documentation for details.

=== Apache-Commons DBCP2 Support
The Apache `commons-dbcp2` database connection pool library is now supported in addition to Tomcat, Hikari and DBCP (v1).

=== Maven Plugin
The `repackage` task of the `spring-boot-maven-plugin` can now be disabled. This can be useful if you want to use `spring-boot:run` but you don't need ``Fat Jars''.

=== Configuration meta-data
The `spring-boot`, `spring-boot-autoconfigure` and `spring-boot-actuator` jars now include additional meta-data files which can be used by tools developers to provide ``code completion'' support in `application.properties` files. An annotation processor is also provided to allow you to generate your own files automatically from `@ConfigurationProperties` classes.

=== Miscellaneous
The following miscellaneous updates are also include with Spring Boot 1.2:

* The `RedisProperties` class now includes a `database` field.
* The `RelaxedDataBinder` class supports `alais` properties.
* Regex expressions can now be used with all `keystosanitize` properties.
* `AnsiOutput` can now be configured using `spring.output.ansi.enabled` property.
* You can now put `favicon.ico` files in `/public`, `/static`, `/resources` folders (next to other static web assets).
* The location of the file written by `ApplicationPidFileWriter` (previously `ApplicationPidListener`) can now be specified using a `spring.pidfile` property or a `PIDFILE` environment variable.
* Tomcat `DataSource` information is now automatically exposed via JMX.
* `SpringBootServletInitializer` subclasses annotated with `@Configuration` no longer need to override the `.configure` method to register themselves a source.
* If you're so inclined, you can now use XML as an `application` properties format.
