Spring Boot 1.4.0 Release Notes 更新日志-01
2016-08-05 16:10
435 查看
Spring Boot 1.4.0 Release Notes
Upgrading
from Spring Boot 1.3
Deprecations
from Spring Boot 1.3
Classes, methods and properties that were deprecated in Spring Boot 1.3 have been removed in this release. Please ensure that you aren’t calling deprecated methods before upgrading.Log4j 1 support has been removed following Apache
EOL announcement.
Renamed
starters
The following starters have been renamed, the old ones will be removed in Spring Boot 2.0spring-boot-starter-ws→
spring-boot-starter-web-services
spring-boot-starter-redis→
spring-boot-starter-data-redis
DataSourceProperties
get methods
Some get…methods from
DataSourcePropertieshave been changed to be more consistent with other
@ConfigurationPropertiesclasses. If you previously directly called any of the following methods
in your code, you will need to migrate to the new
determine…()equivalents:
getDriverClassName()→
determineDriverClassName()
getUrl()→
determineUrl()
getUsername()→
determineUsername()
getPassword()→
determineUsername()
Note | The getmethods are not deprecated but their behavior has changed, make sure that you manually check for usage when upgrading. |
DataSource
binding
Prior to Spring Boot 1.4, auto-configured datasources were bound to the spring.datasourcenamespace. In 1.4, we only bind the common settings to
spring.datasource(see
DataSourceProperties) and
we have defined new specific namespaces for the four connections pools we support (in that order):
spring.datasource.tomcatfor
org.apache.tomcat.jdbc.pool.DataSource
spring.datasource.hikarifor
com.zaxxer.hikari.HikariDataSource
spring.datasource.dbcpfor
org.apache.commons.dbcp.BasicDataSource
spring.datasource.dbcp2for
org.apache.commons.dbcp2.BasicDataSource
If you were using specific settings of the connection pool implementation that you are using, you will have to move that configuration to the relevant namespace. For instance, if you were using Tomcat’s
testOnBorrowflag, you’ll have to
move it from
spring.datasource.test-on-borrowto
spring.datasource.tomcat.test-on-borrow.
If you are using configuration assistance in your IDE, you can now see which settings are available per connection pools rather than having all of them mixed in the
spring.datasourcenamespace. This should make your life much easier figuring
out what implementation supports what features.
JTA
settings binding
Similarly to DataSource binding, JTA provider-specific configuration properties for Atomikos and Bitronix were bound to
spring.jta. They are now bound to
spring.jta.atomikos.propertiesand
spring.jta.bitronix.propertiesrespectively;
the meta-data for these entries has been greatly improved as well.
Hibernate
5
Hibernate 5.0 is now used as the default JPA persistence provider. If you are upgrading from Spring Boot 1.3 you will be moving from Hibernate 4.3 to Hibernate 5.0. Please refer to Hibernatemigration documentation for general upgrade instructions. In addition you should be aware of the following:
Naming
Strategy
SpringNamingStrategyis no longer used as Hibernate 5.1 has removed support for the old
NamingStrategyinterface. A new
SpringPhysicalNamingStrategyis now auto-configured which is used in combination
with Hibernate’s default
ImplicitNamingStrategy. This should be very close to (if not identical) to Spring Boot 1.3 defaults, however, you should check your Database schema is correct when upgrading.
If you were already using Hibernate 5 before upgrading, you may be using Hibernate’s 5 default. If you want to restore them after the upgrade, set this property in your configuration:
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
Generator
mappings
In order to minimize upgrade pain, we set hibernate.id.new_generator_mappingsto
falsefor Hibernate 5. The Hibernate team generally don’t recommend this setting, so if you’re happy to deal with generator changes,
you might want to set
spring.jpa.hibernate.use-new-id-generator-mappingsto
truein your
application.propertiesfile.
Downgrading
to Hibernate 4.3
If you have major problems upgrading to Hibernate 5.0 you can downgrade to the older Hibernate version by overriding the hibernate.versionproperty in your
pom.xml:
4.3.11.Final
Or overriding the
hibernate.versionproperty in your Gradle script:
ext['hibernate.version'] = '4.3.11.Final'
Note | Hibernate 4.3 will not be supported past Spring Boot 1.4. Please raise an issue if you find a bug that prevents you from upgrading. |
@EntityScan
The @org.springframework.boot.orm.jpa.EntityScanannotation has been deprecated and should be replaced with
@org.springframework.boot.autoconfigure.domain.EntityScanor explicit configuration.
For example, if you have following configuration:
import org.springframework.boot.autoconfigure.SpringApplication; import org.springframework.boot.orm.jpa.EntityScan; @SpringBootApplication @EntityScan(basePackageClasses=Customer.class) public class MyApplication { // .... }
If you’re using an auto-configured
LocalContainerEntityManagerFactoryBean, switch to:
import org.springframework.boot.autoconfigure.SpringApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; @SpringBootApplication @EntityScan(basePackageClasses=Customer.class) public class MyApplication { // .... }
Or if you’re defining your own
LocalContainerEntityManagerFactoryBeandrop the
@EntityScanannotation entirely and either call
LocalContainerEntityManagerFactoryBean.setPackagesToScan(…)or make
use of the
EntityManagerFactoryBuilder
packages(…)method:
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory( EntityManagerFactoryBuilder builder) { return builder .dataSource(...) .properties(...) .packages(Customer.class) .build(); }
Test
utilities and classes
Spring Boot 1.4 ships with a new spring-boot-testmodule that contains a completely reorganized
org.springframework.boot.testpackage. When upgrading a Spring Boot 1.3 application you should migrate from the deprecated
classes in the old package to the equivalent class in the new structure. If you’re using Linux or OSX, you can use the following command to migrate code:
find . -type f -name '*.java' -exec sed -i '' \ -e s/org.springframework.boot.test.ConfigFileApplicationContextInitializer/org.springframework.boot.test.context.ConfigFileApplicationContextInitializer/g \ -e s/org.springframework.boot.test.EnvironmentTestUtils/org.springframework.boot.test.util.EnvironmentTestUtils/g \ -e s/org.springframework.boot.test.OutputCapture/org.springframework.boot.test.rule.OutputCapture/g \ -e s/org.springframework.boot.test.SpringApplicationContextLoader/org.springframework.boot.test.context.SpringApplicationContextLoader/g \ -e s/org.springframework.boot.test.SpringBootMockServletContext/org.springframework.boot.test.mock.web.SpringBootMockServletContext/g \ -e s/org.springframework.boot.test.TestRestTemplate/org.springframework.boot.test.web.client.TestRestTemplate/g \ {} \;
Additionally, Spring Boot 1.4 attempts to rationalize and simplify the various ways that a Spring Boot test can be run. You should migrate the following to use the new
@SpringBootTestannotation:
From
@SpringApplicationConfiguration(classes=MyConfig.class)to
@SpringBootTest(classes=MyConfig.class)
From
@ContextConfiguration(classes=MyConfig.class, loader=SpringApplicationContextLoader.class)to
@SpringBootTest(classes=MyConfig.class)
From
@ContextConfiguration(classes=MyConfig.class, loader=SpringApplicationContextLoader.class)to
@SpringBootTest(classes=MyConfig.class)
From
@IntegrationTestto
@SpringBootTest(webEnvironment=WebEnvironment.NONE)
From
@IntegrationTest with @WebAppConfigurationto
@SpringBootTest(webEnvironment=WebEnvironment.DEFINED_PORT)(or
RANDOM_PORT)
From
@WebIntegrationTestto
@SpringBootTest(webEnvironment=WebEnvironment.DEFINED_PORT)(or
RANDOM_PORT)
Tip | Whilst migrating tests you may also want to replace any@RunWith(SpringJUnit4ClassRunner.class)declarations with Spring 4.3’s more readable @RunWith(SpringRunner.class). |
@SpringBootTestannotation refer to the updated
documentation.
TestRestTemplate
The TestRestTemplateclass no longer directly extends
RestTemplate(although it continues to offer the same methods). This allows
TestRestTemplateto be configured as a bean without it being
accidentally injected. If you need access to the actual underlying
RestTemplateuse the
getRestTemplate()method.
Maven
spring-boot.version property
The spring-boot.versionproperty has been removed from the
spring-boot-dependenciespom. See issue
5104 for details.
Integration
Starter
spring-boot-starter-integrationhas been streamlined by removing four modules that are not necessarily used by a typical Spring Integration application. The four modules removed were:
spring-integration-file
spring-integration-http
spring-integration-ip
spring-integration-stream
If your application relies on any of these four modules, you should add an explicit dependency to your pom or build.gradle.
Additionally,
spring-integration-java-dsland
spring-integration-jmxhave now been added to the starter. Using the DSL is the recommended way to configure Spring Integration in your application.
Spring
Batch Starter
The spring-boot-starter-batchstarter no longer depends on an embedded database. If you were relying on this arrangement, please add a database (driver) of your choice, e.g.
org.springframework.boot spring-boot-starter-batch org.hsqldb hsqldb runtime
If you had an exclusion on
hsqldbas you were already configuring your own, you can now remove the exclusion.
Downgrading
Tomcat
As of Tomcat 8.5.4 the tomcat-julimodule is now packaged as part of
tomcat-embedded. Most users won’t notice this change, however, if you manually downgrade to an older version of Tomcat you’ll now need to add the
tomcat-julimodule
yourself. See the how-to
documentation sectionfor updated instructions.
Dispatch
Options Request
The default spring.mvc.dispatch-options-requestproperty has changed from
falseto
trueto align with Spring Framework’s preferred default. If you don’t want
OPTIONSrequests
to be dispatched to
FrameworkServlet.doServiceyou should explicitly set
spring.mvc.dispatch-options-requestto
false.
Forced
character encoding
Forced character encoding now only applies to requests (and not responses). If you want to force encoding for both requests and responses set spring.http.encoding.forceto
true.
Multipart
support
The multipart properties have moved from the multipart.namespace to the
spring.http.multipart.namespace.
Server
header
The ServerHTTP response header is no longer set unless the
server.server-headerproperty is set.
@ConfigurationProperties
default bean names
When a @ConfigurationPropertiesbean is registered via
@EnableConfigurationProperties(SomeBean.class), we used to generate a bean name of the form. As of Spring Boot 1.4, we have changed that
pattern to avoid name clashes if two beans use the same prefix.
The new conventional name is , where is the environment key prefix specified in the
@ConfigurationPropertiesannotation and
Jetty
JNDI support
The spring-boot-starter-jetty"Starter" no longer includes
org.eclipse.jetty:jetty-jndi. If you are using Jetty with JNDI you will now need to directly add this dependency yourself.
Guava
caches
Developers using Guava cache support are advised to migrate to Caffeine.
Remote
Shell
The CRaSHproperties have moved from the
shell.namespace to the
management.shell.namespace. Also, the authentication type should now be defined via
management.shell.auth.type.
Spring
Session auto-configuration improvements
Spring Boot supports more backend stores for Spring Session: alongside Redis, JDBC, MongoDB, Hazelcast and in memory concurrent hash maps are also supported. A new spring.session.store-typemandatory property has been introduced to select
the store Spring Session should be using.
Launch
script identity
When the launch script is determining the application’s default identity, the canonical name of the directory containing the jar will now be used. Previously, if the directory containing the jar was a symlink, the name of the symlink was used. If you requiremore control over the application’s identity, the
APP_NAMEenvironment variable should be used.
MongoDB
3
The default version of Mongo’s Java Driver is now 3.2.2 (from 2.14.2) and spring-boot-starter-data-mongodbhas been updated to use the new, preferred
mongodb-driverartifact.
The auto-configuration for Embedded MongoDB has also been updated to use 3.2.2 as its default version.
Thymeleaf
3
By default, Spring Boot uses Thymeleaf 2.1 but it is now compatible with Thymeleaf 3 as well, check the updateddocumentation for more details.
Executable
jar layout
The layout of executable jars has changed. If you are using Spring Boot’s Maven, Gradle, or Ant support to build your application this change will not affect you. If you are building an executable archive yourself, please be aware that an application’s dependenciesare now packaged in
BOOT-INF/librather than
lib, and an application’s own classes are now packaged in
BOOT-INF/classesrather than the root of the jar.
HornetQ
Support for HornetQ has been deprecated. Users of HornetQ should consider migrating to Artemis.
New
and Noteworthy
Tip | Check the configuration changelog for a complete overview of the changes in configuration. |
相关文章推荐
- Spring Boot 1.4.0 Release Notes 更新日志-02
- Spring Boot 让 MyBatis 打印日志的方法
- spring-boot结合logback日志框架
- 54. spring boot日志升级篇—logback【从零开始学Spring Boot】
- SpringBoot配置log4j输出日志
- SpringBoot+Logback+Sentry(日志监控平台)
- Unix360 01-05 更新日志
- Spring Boot实战之配置使用Sentry上报错误日志(一)
- 50. Spring Boot日志升级篇—log4j【从零开始学Spring Boot】
- 49. spring boot日志升级篇—理论【从零开始学Spring Boot】
- Spring Boot 的彩色日志
- Spring Boot 学习日志(一)
- Spring boot app动态更新数据库表
- Scala开发者的Spring-Boot快速上手指南 01
- 52. spring boot日志升级篇—log4j多环境不同日志级别的控制【从零开始学Spring Boot】
- Spring Boot 在Gradle构建中使用Log4j日志
- Spring Boot的日志管理
- SpringBoot配置log4j输出日志
- spring boot log日志
- Spring Boot实战之配置使用Logback进行日志记录