-
Notifications
You must be signed in to change notification settings - Fork 40.7k
Spring Boot 1.2 Release Notes
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 spring-boot-sample-tomcat7-jsp
and spring-boot-sample-jetty8
samples for downgrade examples.
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.
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.
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
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
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.
Health-related configuration keys have been moved from health
to management.health
for consistency with other management-related properties.
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
.
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
.
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.
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 Boot 1.2 requires Spring Framework 4.1.5 or later and is not compatible with Spring Framework 4.0.
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.
The property spring.data.mongo.repositories.enabled
has been renamed to spring.data.mongodb.repositories.enabled
.
-
The
org.springframework.boot.actuate.system.ApplicationPidListener
class has been superseded byApplicationPidFileWriter
-
The CLI
@EnableRabbitMessaging
annotation has been superseded by@EnableRabbit
from thespring-rabbit
project. -
The
http.mappers.
properties are deprecated in favor of theirspring.jackson.serialization.
equivalents. -
org.springframework.boot.json.SimpleJsonParser
has been deprecated in favor ofBasicJsonParser
to avoid confusion with the ``JSON Simple'' library.
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).
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.
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 JTA section of the reference manual for details.
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.
It is now possible to 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.
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.
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)
.
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.
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
.
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.
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 send emails. The spring.mail.*
properties can be used to customize items such as the SMTP host.
In addition to Tomcat and Jetty, Spring Boot now supports Undertow as an embedded Servlet container. See the reference documentation for details of how to switch.
The spring
CLI command line tool includes a new init
option which can be used to create a project from start.spring.io. For example, to create a new web application you can type:
$ spring init -d=web myapp.zip
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.
SSL can now be configured declaratively by setting the various server.ssl.*
properties. Support is provided for both Tomcat and Jetty. See the reference documentation for more details.
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
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.
If you are using Tomcat as your embedded servlet container metrics are now exposed for the number of active and maximum sessions.
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
now uses the spring.datasource.validation-query
property (if it has been set) to check the health of the database.
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
.
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
.
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.
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.
Auto-configuration support is now provided for Jersey. Refer to reference documentation for details.
The Apache commons-dbcp2
database connection pool library is now supported in addition to Tomcat, Hikari and DBCP (v1).
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''.
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.
The following miscellaneous updates are also include with Spring Boot 1.2:
-
The
RedisProperties
class now includes adatabase
field. -
The
RelaxedDataBinder
class supportsalais
properties. -
Regex expressions can now be used with all
keystosanitize
properties. -
AnsiOutput
can now be configured usingspring.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
(previouslyApplicationPidListener
) can now be specified using aspring.pidfile
property or aPIDFILE
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.