spring boot 各个版本特性
2018-09-20 11:49:04 12 举报
AI智能生成
登录查看完整内容
最全的Spring boot 各个版本的更新及特性
作者其他创作
大纲/内容
spring boot 各个版本特性
Spring boot 1.4(2017年1月)
更新注意事项
Spring Boot 1.3的弃用
在此版本中已删除Spring Boot 1.3中已弃用的类,方法和属性。请确保在升级之前不要调用已弃用的方法。
Apache EOL发布后,已删除Log4j 1支持。
重新命名为首发
以下启动器已重命名,旧的将在Spring Boot 1.5中删除
spring-boot-starter-ws → spring-boot-starter-web-services
spring-boot-starter-redis → spring-boot-starter-data-redis
DataSourceProperties获取方法
一些get…方法DataSourceProperties已被更改为与其他@ConfigurationProperties类更一致。如果您之前在代码中直接调用了以下任何方法,则需要迁移到新的determine…()等价物:
getDriverClassName() → determineDriverClassName()
getUrl() → determineUrl()
getUsername() → determineUsername()
getPassword() → determineUsername()
注意这些get方法不会被弃用,但它们的行为已经改变,请确保在升级时手动检查使用情况。
DataSource绑定
在Spring Boot 1.4之前,自动配置的数据源绑定到spring.datasource命名空间。在1.4中,我们只将公共设置绑定到spring.datasource(请参阅参考资料DataSourceProperties),我们为我们支持的四个连接池(按此顺序)定义了新的特定命名空间:
spring.datasource.tomcat 对于 org.apache.tomcat.jdbc.pool.DataSource
spring.datasource.hikari 对于 com.zaxxer.hikari.HikariDataSource
spring.datasource.dbcp 对于 org.apache.commons.dbcp.BasicDataSource
spring.datasource.dbcp2 对于 org.apache.commons.dbcp2.BasicDataSource
如果您使用的是正在使用的连接池实现的特定设置,则必须将该配置移动到相关的命名空间。例如,如果您使用Tomcat的testOnBorrow标志,则必须将其spring.datasource.test-on-borrow移至spring.datasource.tomcat.test-on-borrow。
如果在IDE中使用配置帮助,现在可以查看每个连接池可用的设置,而不是在spring.datasource命名空间中混合所有设置。这应该可以让您的生活更容易找出哪些实现支持哪些功能。
JTA设置绑定
与此类似DataSource binding,Atomikos和Bitronix的JTA提供程序特定的配置属性受到约束spring.jta。他们现在必然要spring.jta.atomikos.properties和spring.jta.bitronix.properties分别; 这些条目的元数据也得到了很大改善。
Hibernate 5
Hibernate 5.0现在用作默认的JPA持久性提供程序。如果从Spring Boot 1.3升级,您将从Hibernate 4.3迁移到Hibernate 5.0。
命名策略
SpringNamingStrategy不再使用,因为Hibernate 5.1已经删除了对旧NamingStrategy接口的支持。SpringPhysicalNamingStrategy现在自动配置了一个新的,它与Hibernate的默认值结合使用ImplicitNamingStrategy。这应该与Spring Boot 1.3默认值非常接近(如果不相同),但是,升级时应检查数据库架构是否正确。
如果您在升级之前已经在使用Hibernate 5,那么您可能正在使用Hibernate的5默认设置。如果要在升级后还原它们,请在配置中设置此属性:
spring.jpa.hibernate.naming.physical策略= org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
生成器映射
为了尽量减少升级的痛苦,我们设置hibernate.id.new_generator_mappings到false对Hibernate 5. Hibernate团队一般不建议使用此设置,因此,如果你很高兴来处理生成的变化,你可能需要设置spring.jpa.hibernate.use-new-id-generator-mappings到true您的application.properties文件。
降级为Hibernate 4.3
如果您在升级到Hibernate 5.0时遇到重大问题,可以通过覆盖以下hibernate.version属性来降级到较旧的Hibernate版本pom.xml:
分支主题
或者覆盖hibernate.versionGradle脚本中的属性:
Spring Boot 1.4不支持Hibernate 4.3。
@EntityScan
该@org.springframework.boot.orm.jpa.EntityScan注释已弃用,应替换@org.springframework.boot.autoconfigure.domain.EntityScan或明确的配置。
例如,如果您有以下配置:
如果您使用的是自动配置LocalContainerEntityManagerFactoryBean,请切换到:
或者,如果您要定义自己完全LocalContainerEntityManagerFactoryBean删除@EntityScan注释并调用LocalContainerEntityManagerFactoryBean.setPackagesToScan(…)或使用该EntityManagerFactoryBuilder packages(…)方法:
测试实用程序和类
Spring Boot 1.4附带一个spring-boot-test包含完全重组的org.springframework.boot.test软件包的新模块。升级Spring Boot 1.3应用程序时,您应该从旧包中的已弃用类迁移到新结构中的等效类。如果您使用的是Linux或OSX,则可以使用以下命令迁移代码:
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 \\
{} \\;
此外,Spring Boot 1.4尝试合理化和简化Spring Boot测试的各种运行方式。您应该迁移以下内容以使用新@SpringBootTest注释:
从@SpringApplicationConfiguration(classes=MyConfig.class)到@SpringBootTest(classes=MyConfig.class)
从@IntegrationTest到@SpringBootTest(webEnvironment=WebEnvironment.NONE)
从@IntegrationTest with @WebAppConfiguration到@SpringBootTest(webEnvironment=WebEnvironment.DEFINED_PORT)(或RANDOM_PORT)
从@WebIntegrationTest到@SpringBootTest(webEnvironment=WebEnvironment.DEFINED_PORT)(或RANDOM_PORT)
在迁移测试时,您可能还希望@RunWith(SpringJUnit4ClassRunner.class)用Spring 4.3 替换任何声明更具可读性@RunWith(SpringRunner.class)。
TestRestTemplate
该TestRestTemplate班不再直接扩展RestTemplate(尽管它继续提供相同的方法)。这允许TestRestTemplate配置为bean而不会意外注入。如果需要访问实际的底层RestTemplate使用getRestTemplate()方法。
Maven spring-boot.version属性
该spring-boot.version物业已从spring-boot-dependenciespom中移除。
集成启动器
spring-boot-starter-integration通过删除一些典型的Spring Integration应用程序不一定使用的模块,简化了这一过程。删除的四个模块是:
spring-integration-file
spring-integration-http
spring-integration-ip
spring-integration-stream
如果您的应用程序依赖于这四个模块中的任何一个,则应该向pom或build.gradle添加显式依赖项。
此外,spring-integration-java-dsl和spring-integration-jmx现在已经被添加到启动。使用DSL是在应用程序中配置Spring Integration的推荐方法。
Spring Batch Starter
在spring-boot-starter-batch启动不再依赖的嵌入式数据库。如果您依赖这种安排,请添加您选择的数据库(驱动程序),例如
如果您hsqldb已经配置了自己的排除项,则现在可以删除排除项。
降级Tomcat
从Tomcat 8.5.4开始,该tomcat-juli模块现已打包成为其中的一部分tomcat-embedded。大多数用户都不会注意到这种变化,但是,如果您手动降级到较旧版本的Tomcat,您现在需要自己添加tomcat-juli模块。
Dispatch Options Request
默认spring.mvc.dispatch-options-request属性已从false更改true为与Spring Framework的首选默认值对齐。如果您不希望将OPTIONS请求分派给FrameworkServlet.doService您,则应明确设置spring.mvc.dispatch-options-request为false。
强制字符编码
强制字符编码现在仅适用于请求(而不是响应)。如果要对请求和响应设置spring.http.encoding.force为强制编码true。
多方支持
多部分属性已从命名空间移动到命名空间。multipart.spring.http.multipart.
服务器头
所述ServerHTTP响应报头中不再设置除非server.server-header属性设置。
@ConfigurationProperties默认的bean名称
当@ConfigurationPropertiesbean通过注册时@EnableConfigurationProperties(SomeBean.class),我们用来生成表单的bean名称<prefix>.CONFIGURATION_PROPERTIES。从Spring Boot 1.4开始,我们更改了该模式,以避免名称冲突,如果两个bean使用相同的前缀。
新的常规名称是<prefix>-<fqn>,注释中<prefix>指定的环境键前缀@ConfigurationProperties和<fqn> bean的完全限定名称。如果注释未提供任何前缀,则仅使用bean的完全限定名称。
Jetty JNDI支持
在spring-boot-starter-jetty“入门”不再包括org.eclipse.jetty:jetty-jndi。如果您使用Jetty和JNDI,您现在需要自己直接添加此依赖项。
Guava caches
建议使用Guava缓存支持的开发人员迁移到Caffeine。
远程外壳
该CRaSH性质已经从移动的命名空间的命名空间。此外,现在应该通过定义身份验证类型。shell.management.shell.management.shell.auth.type
Spring Session自动配置改进
Spring Boot支持Spring Session的更多后端存储:与Redis,JDBC,MongoDB,Hazelcast和内存并发哈希映射一起支持。spring.session.store-type引入了一个新的强制属性来选择Spring Session应该使用的商店。
启动脚本标识
当启动脚本确定应用程序的默认标识时,现在将使用包含jar的目录的规范名称。以前,如果包含jar的目录是符号链接,则使用符号链接的名称。如果您需要更多地控制应用程序的标识,APP_NAME则应使用环境变量。
MongoDB 3
Mongo的Java驱动程序的默认版本现在是3.2.2(从2.14.2开始),spring-boot-starter-data-mongodb并且已经更新为使用新的首选mongodb-driver工件。
Embedded MongoDB的自动配置也已更新为使用3.2.2作为其默认版本。
Thymeleaf 3
默认情况下,Spring Boot使用Thymeleaf 2.1,但它现在也与Thymeleaf 3兼容
可执行的jar布局
可执行jar的布局已经改变。如果您使用Spring Boot的Maven,Gradle或Ant支持来构建应用程序,则此更改不会对您产生影响。如果您自己构建可执行存档,请注意应用程序的依赖项现在打包BOOT-INF/lib而不是lib,应用程序自己的类现在打包在BOOT-INF/classesjar而不是jar的根目录中。
Jersey类路径扫描限制
对可执行jar的布局的更改意味着Jersey的类路径扫描中的限制现在会影响可执行jar文件以及可执行war文件。要解决此问题,您希望由Jersey扫描的类应打包在jar中并作为依赖项包含在内BOOT-INF/lib。然后应将Spring Boot启动程序配置为在启动时解压缩这些jar,以便Jersey可以扫描其内容。
与集成测试 maven-failsafe-plugin
从Failsafe开始2.19,target/classes不再在类路径上,而是使用项目的构建jar。由于可执行jar布局的更改,插件将无法找到您的类。有两种方法可以解决此问题:
降级到2.18.1让你用target/classes,而不是
配置为目标spring-boot-maven-plugin使用分类器repackage。这样,原始jar将可用并由插件使用。例如
HornetQ的
对HornetQ的支持已被弃用。HornetQ的用户应该考虑迁移到Artemis。
@Transactional 默认为cglib代理
当Boot自动配置事务管理时,proxyTargetClass现在设置为true(意味着创建了cglib代理而不是要求bean实现接口)。如果要将该行为与未自动配置的其他方面对齐,则需要立即显式启用该属性:
@EnableCaching(proxyTargetClass = true)
更新内容
Spring Framework 4.3
Spring Boot 1.4构建于Spring Framework 4.3之上并需要它。Spring Framework 4.3中有许多很好的改进,包括新的Spring MVC @RequestMapping注释。
请注意,Spring Framework 4.3中的测试框架需要JUnit 4.12。
第三方库升级
许多第三方库已升级到最新版本。更新包括Jetty 9.3,Tomcat 8.5,Jersey 2.23,Hibernate 5.0,Jackson 2.7,Solr 5.5,Spring Data Hopper,Spring Session 1.2,Hazelcast 3.6,Artemis 1.3,Ehcache 3.1,Elasticsearch 2.3,Spring REST Docs 1.1,Spring AMQP 1.6和Spring整合4.3。
Couchbase支持
现在为Couchbase提供完全自动配置支持。您可以通过添加“Starter”并提供一些配置来轻松访问a Bucket和Clusterbean spring-boot-starter-data-couchbase:
也可以使用Couchbase作为Spring Data的后备存储Repository或作为CacheManager。
Neo4J支持
现在为Neo4J提供了自动配置支持。您可以连接到远程服务器或运行嵌入式Neo4J服务器。您也可以使用Neo4J来支持Spring数据Repository,例如:
Redis Spring Data存储库
Redis现在可用于支持Spring Data存储库。
Narayana交易经理支持
现在,Narayana事务管理器包含自动配置支持。如果您需要JTA支持,您可以选择Narayana,Bitronix或Atomkos。
Caffeine缓存支持
为Caffeine v2.2(Java 8重写Guava的缓存支持)提供了自动配置。现有的Guava缓存用户应考虑迁移到Caffeine,因为将来的版本中将删除Guava缓存支持。
Elasticsearch Jest支持
如果Jest在类路径上,Spring Boot会自动配置a JestClient和一个专用HealthIndicator的。这允许您使用Elasticsearch即使spring-data-elasticsearch不在类路径上。
启动失败分析
Spring Boot现在将执行常见启动故障分析并提供有用的诊断信息,而不是简单地记录异常及其堆栈跟踪。例如,由于嵌入式servlet容器的端口正在使用而导致的启动失败在早期版本的Spring Boot中看起来像这样:
在1.4中,它将如下所示:
如果您仍希望查看基础原因的堆栈跟踪,请启用调试日志记录
org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter。
Image Banners
您现在可以使用图像文件来呈现ASCII艺术横幅。删除一个banner.gif,banner.jpg或banner.png文件导入src/main/resources,系统将自动转换为ASCII。您可以使用banner.image.width和banner.image.height属性调整大小,或使用banner.image.invert反转颜色。
RestTemplate构建器
一个新的RestTemplateBuilder可以用来轻松创建一个RestTemplate合理的默认值。默认情况下,内置版RestTemplate将尝试使用ClientHttpRequestFactory类路径中最合适的可用内容,并将知道MessageConverter要使用的实例(包括Jackson)。构建器包含许多可用于快速配置a的有用方法RestTemplate。例如,要添加BASIC auth支持,您可以使用:
自动配置TestRestTemplate现在也使用了RestTemplateBuilder。
JSON组件
@JsonComponent现在为自定义Jackson JsonSerializer和/或JsonDeserializer注册提供了新注释。这可以是解耦JSON序列化逻辑的有用方法:
此外,spring也引导现在提供JsonObjectSerializer和JsonObjectDeserializer基地序列化对象时提供标准版本的杰克逊有用的替代课程。
基于约定的错误页面
现在可以通过遵循基于约定的方法来创建给定状态代码的自定义错误页面。使用状态代码作为文件名创建静态HTML文件/public/error或添加模板/templates/error。例如,要注册您可以添加的自定义404文件src/main/resource/public/error/404.html。
统一@EntityScan注释
org.springframework.boot.autoconfigure.domain.EntityScan现在可用于指定用于JPA,Neo4J,MongoDB,Cassandra和Couchbase的包。因此,org.springframework.boot.orm.jpa.EntityScan现在不推荐使用JPA特定的。
ErrorPageRegistry
无论使用嵌入式servlet容器,New ErrorPageRegistry和ErrorPageRegistrar接口都允许以一致的方式注册错误页面。该ErrorPageFilter班已更新,以它现在是ErrorPageRegistry不是假的ConfigurableEmbeddedServletContainer。
PrincipalExtractor
PrincipalExtractor如果需要Principal使用自定义逻辑提取OAuth2,现在可以使用该接口。
测试改进
Spring Boot 1.4包括对测试支持的重大改进。测试类和实用程序现在在专用spring-boot-test和spring-boot-test-autoconfigurejar中提供(尽管大多数用户将继续通过spring-boot-starter-test“Starter”获取它们)。我们已将AssertJ,JSONassert和JsonPath依赖项添加到测试启动器中。
@SpringBootTest
使用Spring Boot 1.3,有多种方法可以编写Spring Boot测试。你可以使用@SpringApplicationConfiguration,@ContextConfiguration用的SpringApplicationContextLoader,@IntegrationTest或@WebIntegrationTest。使用Spring Boot 1.4,单个@SpringBootTest注释将替换所有这些注释。
用@SpringBootTest结合@RunWith(SpringRunner.class),并设置webEnvironment取决于你想要写的测试类型属性。
经典的集成测试,带有模拟的servlet环境:
Web集成测试,运行在定义的端口上侦听的实时服务器:
Web集成测试,运行在随机端口上侦听的实时服务器:
自动检测测试配置
现在可以自动检测大多数测试的测试配置。如果遵循Spring Boot推荐的用于构造代码的约定,@SpringBootApplication则在未定义显式配置时将加载该类。如果需要加载其他@Configuration类,可以将其作为嵌套内部类包含在测试中,或者使用classes属性@SpringBootTest。
Mocking and spying beans
ApplicationContext为了测试目的,想要用模拟替换你的单个bean是很常见的。使用Spring Boot 1.4,现在就像在测试中使用@MockBean以下内容注释字段一样简单:
@SpyBean如果您想监视现有bean而不是使用完整模拟,也可以使用它。
自动配置的测试
对于测试而言,完整的应用程序自动配置有时会过度,您通常只想自动配置应用程序的特定“片段”。Spring Boot 1.4引入了许多专门的测试注释,可用于测试应用程序的特定部分:
@JsonTest - 用于测试JSON编组和解组。
@WebMvcTest- @Controllers使用MockMVC 测试Spring MVC 。
@RestClientTest - 用于测试RestTemplate调用。
@DataJpaTest - 用于测试Spring Data JPA元素
许多注释提供了特定于测试的附加自动配置。例如,如果你使用@WebMvcTest,你可以@Autowire完全配置的MockMvc实例。
JSON AssertJ断言
新JacksonTester,GsonTester并且BasicJsonTester类可以组合使用与AssertJ测试JSON编组和解组。测试人员可以与@JsonTest注释一起使用,也可以直接在测试类上使用:
@RestClientTest
这个@RestClientTest,如果你想测试REST客户注释可以使用。默认情况下,它将自动配置Jackson和GSON支持,配置RestTemplateBuilder并添加支持MockRestServiceServer。
Spring REST Docs的自动配置
结合MockMvc上述自动配置支持,引入了Spring REST Docs的自动配置。可以使用新@AutoConfigureRestDocs注释启用REST文档。这将导致MockMvc实例自动配置为使用REST Docs,并且无需使用REST Docs的JUnit规则。
测试工具
spring-boot-starter-test现在带来了AssertJ断言库。
org.springframework.boot.test包中的测试实用程序已移至spring-boot-test专用工件。
执行器信息端点改进
您现在可以使用该InfoContributor接口来注册将信息暴露给/info执行器端点的bean 。开箱即用支持:
从git-commit-id-pluginMaven或gradle-git-propertiesGradle插件生成的完整或部分Git信息(设置management.info.git.mode=full为公开完整详细信息)
构建从Spring Boot Maven或Gradle插件生成的信息。
来自环境的自定义信息(任何属性启动info.*)
MetricsFilter的改进
现在MetricsFilter可以以经典的“合并”形式提交指标,或按HTTP方法分组。使用endpoints.metrics.filter属性更改配置:
Spring Session JDBC Initializer
如果将Spring Session配置为使用JDBC存储,则现在会在启动时自动创建架构。
Artemis / HornetQ的安全连接
Spring Boot现在可以连接到安全的Artemis / HornetQ代理。
注释处理
Apache HttpCore 4.4.5 删除了一些注释。如果您使用注释处理器并且使用其中一个已删除的注释对类进行子类化,则这是二进制不兼容的更改。例如,如果该类正在使用,@Immutable您将看到编译时注释处理失败[ERROR] diagnostic: error: cannot access org.apache.http.annotation.Immutable。
通过降级到HttpCore 4.4.4或者最好通过构造代码来避免问题,以便有问题的类不受编译时注释处理的影响。
其他
server.jetty.acceptors和server.jetty.selectors属性已添加以配置Jetty接受器和选择器的数量。
server.max-http-header-size并且server.max-http-post-size可以用来限制为HTTP标头和HTTP POST的最大尺寸。设置适用于Tomcat,Jetty和Undertow。
现在可以使用配置Tomcat的最小备用线程数 server.tomcat.min-spare-threads
现在在application.yml文件中支持配置文件否定。!在spring.profiles值中使用熟悉的前缀
执行器公开一个headdump返回GZip压缩hprof堆转储文件的新端点
Spring Mobile现在为所有支持的模板引擎自动配置
Spring Boot maven插件允许system使用new includeSystemScope属性捆绑范围的工件
spring.mvc.log-resolved-exception 当a解决异常时,可以自动记录警告 HandlerExceptionResolver
spring.data.cassandra.schema-action 您将习惯于自定义要在启动时采取的架构操作
Spring Boot的胖jar格式现在应该消耗更少的内存
现在通过该spring.http.encoding.mapping.<locale>=<charset>属性支持Locale to Charset映射
默认情况下,使用的语言环境spring.mvc.locale现在由请求的Accept-Language标头覆盖。要恢复忽略标头的1.3行为,请设置spring.mvc.locale-resolver为fixed。
Spring Boot 1.4中的弃用
由于从Spring Framework 4.3开始不再使用支持,因此不推荐使用Velocity支持。
一些构造函数UndertowEmbeddedServletContainer已被弃用(大多数使用应该不受影响)。
不推荐使用注释的locations和merge属性,@ConfigurationProperties而是直接配置注释Environment。
SpringApplication.printBanner不应再使用受保护的方法来打印自定义横幅。请改用Banner界面。
InfoEndpoint.getAdditionalInfo已弃用受保护的方法以支持该InfoContributor接口。
org.springframework.boot.autoconfigure.test.ImportAutoConfiguration已被转移到org.springframework.boot.autoconfigure。
org.springframework.boot.test包中的所有类都已被弃用。
PropertiesConfigurationFactory.setProperties(Properties)不赞成使用PropertySources。
org.springframework.boot.context.embedded包中的几个类已被弃用并重新定位到org.springframework.boot.web.servlet。
org.springframework.boot.context.web包中的所有类都已被弃用和重新定位。
在spring-boot-starter-ws“入门”已更名为spring-boot-starter-web-services。
在spring-boot-starter-redis“入门”已更名为spring-boot-starter-data-redis。
在spring-boot-starter-hornetq启动和自动配置已被弃用,取而代之的使用spring-boot-starter-artemis
management.security.role 已被弃用赞成 management.security.roles
该@org.springframework.boot.orm.jpa.EntityScan注释已弃用,取而代之的@org.springframework.boot.autoconfigure.domain.EntityScan或显式配置。
TomcatEmbeddedServletContainerFactory.getValves()已被弃用赞成getContextValves()。
org.springframework.boot.actuate.system.EmbeddedServerPortFileWriter 已被弃用赞成 org.springframework.boot.system.EmbeddedServerPortFileWriter
org.springframework.boot.actuate.system.ApplicationPidFileWriter 已被弃用赞成 org.springframework.boot.system.ApplicationPidFileWriter
Property重命名
spring.jackson.serialization-inclusion应该换成spring.jackson.default-property-inclusion。
spring.activemq.pooled应该换成spring.activemq.pool.enabled。
spring.jpa.hibernate.naming-strategy应该换成spring.jpa.hibernate.naming.strategy。
server.tomcat.max-http-header-size应该换成server.max-http-header-size。
Spring boot 1.5(2017年2月)
Spring Boot 1.4的弃用
在此版本中已删除了Spring Boot 1.4中不推荐使用的类,方法和属性。请确保在升级之前不要调用已弃用的方法。特别是,HornetQ和Velocity支持已被删除。
现在已经删除了在Spring Boot 1.4中重命名的以下启动程序,如果您收到“未解决的依赖项”错误,请检查您是否正在使用正确命名的启动程序:
@ConfigurationProperties验证
如果您有@ConfigurationProperties使用JSR-303约束注释的类,则现在应该另外注释它们@Validated。现有验证将继续有效,但会记录警告。将来,没有的课程@Validated根本不会被验证。
Spring Session store
以前,如果您没有特定配置的Spring Session和Redis,Redis会自动用于存储会话。您现在需要指定商店类型; Spring Session与Redis的现有用户应在其配置中添加以下内容:
spring.session.store-type = redis
执行器安全性
执行器“敏感”端点现在默认是安全的(即使不依赖于“Spring Security”)。如果您现有的Spring Boot 1.4应用程序使用Spring Security(并且没有任何自定义安全配置),则应该像以前一样工作。如果现有的Spring Boot 1.4应用程序具有自定义安全配置,并且您希望对敏感端点具有开放访问权限,则需要在安全配置中明确配置它。如果您正在升级并不会对Spring Security的依赖Spring的启动1.4应用程序,并要打开访问保留到你的敏感终点,你将需要设置management.security.enabled到false。
访问端点所需的默认角色也已更改ADMIN为ACTUATOR。这是为了防止在您将ADMIN角色用于其他目的时意外暴露端点。如果要恢复Spring Boot 1.4行为,请将management.security.roles属性设置为ADMIN。
InMemoryMetricRepository
将InMemoryMetricRepository不再直接实现MultiMetricRepository。InMemoryMultiMetricRepository现在注册了一个新bean,它满足MultiMetricRepository接口并由常规支持InMemoryMetricRepository。由于大多数用户将与MetricRepository或MultiMetricRepository交互(而不是内存实现),因此此更改应该是透明的。
spring.jpa.database
在spring.jpa.database现在能够自动检测从共同数据库spring.datasource.url属性。如果您已手动定义spring.jpa.database,并且使用公共数据库,则可能需要尝试完全删除该属性。
有几个数据库有多个Dialect(例如,Microsoft SQL Server有3个),因此我们可能会配置一个与您正在使用的数据库版本不匹配的数据库。如果您之前有过工作设置,并希望依靠Hibernate自动检测Dialect,请设置spring.jpa.database=default。或者,您可以随时使用该spring.jpa.database-platform属性设置方言。
@IntegrationComponentScan
Spring Integration的@IntegrationComponentScan注释现在已自动配置。如果您遵循建议的项目结构,则应尝试将其删除。
ApplicationStartedEvent
如果您当前正在侦听ApplicationStartedEvent代码,则应重构使用ApplicationStartingEvent。我们将此类重命名为更准确地反映它的作用。
Spring Integration Starter
该spring-boot-starter-integrationPOM不再包括spring-integration-jmx。如果您需要Spring Integration JMX支持,则应自行包含spring-integration-jmx依赖项。
Devtools默认排除在外
现在默认情况下,Maven和Gradle插件都不包括spring-boot-devtools在“胖”罐子中包装罐子。如果您正在使用devtools远程支持你现在需要明确设置excludeDevtools属性在你build.gradle或pom.xml文件。
Gradle 1.x
Spring Boot Gradle插件不再与Gradle 1.x和早期版本的Gradle 2.x兼容。请确保您是Gradle 2.9或更高版本。
远程CRaSH shell
不幸的是,Spring Boot用来提供远程SSH支持的CRaSH项目不再被主动维护。遗憾的是,我们已经决定弃用远程执行器SSH支持,并且计划在Spring Boot 2.0中完全删除它。
OAuth 2资源过滤器
OAuth2资源过滤器的默认顺序已从更改3为SecurityProperties.ACCESS_OVERRIDE_ORDER - 1。这将它置于执行器端点之后但在基本认证过滤器链之前。可以通过设置恢复默认值security.oauth2.resource.filter-order = 3
JSP servlet
默认情况下,JSP servlet不再处于开发模式。使用DevTools时会自动启用开发模式。它也可以通过设置明确启用server.jsp-servlet.init-parameters.development=true。
被忽略的路径和 @EnableWebSecurity
在Spring Boot 1.4及更早版本中,Actuator始终会配置一些被忽略的路径,而不管其使用情况如何@EnableWebSecurity。这已在1.5中更正,因此使用@EnableWebSecurity将关闭Web安全的所有自动配置,从而允许您完全控制。
许多第三方库已升级到最新版本。更新包括Spring Data Ingalls,Jetty 9.4,JooQ 3.9,AssertJ 2.6.0,Hikari 2.5和Neo4J 2.1。几个Maven插件也已升级。
记录器端点
新的执行器loggers端点允许您即时查看和更改应用程序日志记录级别。有一个JMX和MVC端点可用。例如,要使用MVC端点更改日志记录级别,可以使用以下JSON 发出POSTto/loggers/com.yourcorp.application
要使用JMX端点更新记录器,您将使用该setLogLevel操作。
Apache Kafka支持
Spring Boot 1.5包括通过该spring-kafka项目为Apache Kafka提供的自动配置支持。要使用Kafka,只需包含spring-kafka`depenency and configure the appropriate `spring.kafka.*应用程序属性即可。
从Kafka接收消息就像注释方法一样简单:
Cloud Foundry执行器扩展
Spring Boot的执行器模块现在包含在部署到兼容的Cloud Foundry实例时激活的其他支持。该/cloudfoundryapplication路径为所有NamedMvcEndpointbean 提供了另一种安全路径。
Cloud Foundry管理UI可以利用端点显示其他执行器信息。例如,Pivotal Cloud Foundry在应用程序状态旁边显示健康信息:
LDAP支持
Spring Boot现在为任何兼容的LDAP服务器提供自动配置,并支持Unbounded的嵌入式内存LDAP服务器。
AuditEvents端点支持
AuditEventsJmxEndpoint现在,新的bean允许您查询以前AuditEvents通过JMX 记录的内容。MBean AuditEventRepository find通过getData操作公开方法。审核会自动记录以进行身份验证和授权事件,您可以使用以下方式记录自己的事件AuditEventRepository。该信息也由新的/auditeventsMVC端点公开。
事务管理器属性
现在可以配置PlatformTransactionManager使用spring.transaction.*属性自动配置的各个方面。目前支持“default-timeout”和rollback-on-commit-failure属性。
JmxEndpoint接口
JmxEndpoint引入了一个新接口,允许您开发仅通过JMX公开的执行器端点。该接口与MvcEndpoint仅为MVC端点提供的接口非常相似。
Vendor specific flyway migrations
您现在可以定义特定于数据库供应商的flyway迁移。要使用特定于供应商的迁移,请flyway.locations按如下所示设置属性:
弃用 level
现在可以为元数据中的属性定义弃用级别。级别可以是warning(默认)或error。
以下是在Spring Boot 2中移动的属性的手动元数据示例:
到目前为止,当不再使用已弃用的属性时,我们会完全删除元数据。此新功能允许将属性(server.context-parameters此处)标记为错误。您最喜欢的IDE的较新版本应该使用它来提供帮助。
测试更新
现在可以排除通常由@Test…注释导入的自动配置。@Test…现在,所有现有注释都包含一个excludeAutoConfiguration属性。或者,您可以@ImportAutoConfiguration(exclude=…)直接添加到测试中。
Spring Boot 1.5还引入了一个新的@JdbcTest注释,可用于测试直接的JDBC交互。
自定义jar layouts
Spring Boot Maven和Gradle插件现在支持自定义胖jar布局。此功能允许在Spring Boot之外开发此类实验布局。
JmsTemplate自定义
现在可以JmsTemplate使用spring.jms.template.*命名空间中提供的其他密钥自定义自动配置。
Mockito 2.x现在可以使用@MockBean(与Mockito 1.9兼容)
嵌入式启动脚本现在支持a force-stop
已添加对Cassandra的新健康检查
Cassandra用户定义的类型现在已经解析(通过Spring Data SimpleUserTypeResolver)
该skip属性现在适用于Spring Boot Maven插件run,'stop'和'repackage`目标
如果main找到多个方法类,Maven和Gradle插件现在将自动使用带注释的方法@SpringBootApplication
Spring Boot 1.5中的弃用
TomcatEmbeddedServletContainerFactory.setTldSkip 已被弃用赞成 setTldSkipPatterns
ApplicationStartedEvent 已被取代 ApplicationStartingEvent
几个常量LoggingApplicationListener已被替换为版本LogFile
使用Guava进行缓存已被弃用,因为将在Spring Framework 5中删除Guava支持。升级到Caffeine
CRaSH支持已被弃用,因为它不再被主动维护
EndpointMBeanExporter在引入之后,已经弃用了几种受保护的方法JmxEndpoint
earchStrategy.PARENTS已被取代SearchStrategy.ANCESTORS。
不推荐使用Apache DBCP支持,而使用DBCP 2
该server.undertow.buffers-per-region属性已被弃用,因为它未被使用(参见UNDERTOW-587)
@AutoConfigureTestDatabase已被转移org.springframework.boot.test.autoconfigure.orm.jpa到org.springframework.boot.test.autoconfigure.jdbc
属性重命名
该server.max-http-post-size属性已被技术特定的变体所取代(例如server.tomcat.max-http-post-size)
该spring.data.neo4j.session.scope物业已被删除。
1.5 ->(升级) 2.0注意事项
在你开始之前
首先,Spring Boot 2.0需要Java 8或更高版本。不再支持Java 6和7。它还需要Spring Framework 5.0。
随着Spring开机2.0中,许多配置属性被重新命名/删除,开发者需要更新他们的application.properties/ application.yml相应。为了帮助您,Spring Boot提供了一个新spring-boot-properties-migrator模块。一旦作为项目的依赖项添加,这不仅会在启动时分析应用程序的环境和打印诊断,还会在运行时为您临时迁移属性。这是您在应用程序迁移期间必须具备的功能:
runtime(\"org.springframework.boot:spring-boot-properties-migrator\")
构建Spring Boot应用程序
Spring Boot Maven插件
现在作为属性公开的插件配置属性都spring-boot以一致性的前缀开头,并避免与其他插件发生冲突。
例如,以下命令prod使用命令行启用配置文件:
Surefire默认值
自定义包含/排除模式已与最新的Surefire默认值保持一致。如果您依赖我们的,请相应地更新您的插件配置。他们过去如下:
Spring Boot Gradle插件
Spring Boot的Gradle插件已经在很大程度上被重写,以实现许多重大改进。
依赖管理
Spring Boot的Gradle插件不再自动应用依赖项管理插件。相反,Spring Boot的插件现在通过导入spring-boot-dependencies BOM的正确版本来响应正在应用的依赖管理插件。这使您可以更好地控制配置依赖关系管理的方式和时间。
对于大多数应用程序来说,应用依赖项管理插件就足够了:
建立可执行的罐子和战争
该bootRepackage任务已分别替换为构建可执行jar和战争的任务bootJar和bootWar任务。这些jar和war任务不再涉及。
配置更新
这BootRun,BootJar和BootWar任务现在都使用mainClassName的属性来配置主类的名称。这使得三个特定于Boot的任务彼此一致,并且还将它们与Gradle自己的应用程序插件对齐。
Spring Boot功能
默认代理策略
Spring Boot现在默认使用CGLIB代理,包括AOP支持。如果需要基于接口的代理,则需要设置spring.aop.proxy-target-class为false。
SpringApplication
网络环境
pring Boot应用程序现在可以在更多模式下运行,因此spring.main.web-environment现在不推荐使用属性spring.main.web-application-type来提供更多控制。
如果要确保应用程序无法启动Web服务器,则必须将属性更改为:
Spring Boot应用程序事件更改
我们添加了一个新活动ApplicationStartedEvent。 ApplicationStartedEvent在刷新上下文之后但在调用任何应用程序和命令行运行程序之前发送。 ApplicationReadyEvent在调用任何应用程序和命令行运行程序后发送。它表示应用程序已准备好为请求提供服务。
Banner
在我们努力限制Spring Boot使用的根命名空间的数量时,已将与横幅相关的属性重新定位到spring.banner。
外化配置
轻松绑定
与轻松绑定相关的规则已经收紧
这种新的轻松绑定具有以下几个优点:
无需担心密钥的结构@ConditionalOnProperty:您现在必须使用规范格式(acme.my-property而不是acme.myProperty),支持的宽松变体将以透明方式工作。如果您使用的是prefix属性,现在只需使用name或value属性放置完整键即可。
RelaxedPropertyResolver不再可用,因为它Environment会自动处理:env.getProperty(\"com.foo.my-bar\")找到一个com.foo.myBar属性。
该org.springframework.boot.bind软件包不再可用,并由新的宽松绑定基础架构取代。特别是,RelaxedDataBinder朋友们已经换成了新的BinderAPI。以下示例MyProperties从app.acme前缀绑定
由于现在内置了轻松的绑定,只要使用其中一种支持的格式,您就可以请求任何属性而无需关心案例:
绑定静态方法
虽然绑定静态属性(使用staticgetter和setter对)在Spring Boot中工作1.x,但我们从未真正打算提供这样的功能,而且从Spring Boot 2开始就不再可能了。
@ConfigurationProperties 验证
如果要打开验证,现在必须对您的@ConfigurationProperties对象进行注释@Validated。
配置位置
spring.config.location配置的行为已得到修复; 它之前在默认列表中添加了一个位置,现在它取代了默认位置。如果你依赖于以前处理它的方式,你现在应该使用它spring.config.additional-location。
开发Web应用程序
嵌入式容器包结构
为了支持反应用例,嵌入式容器包结构已经被非常广泛地重构。 EmbeddedServletContainer已重命名为,WebServer并org.springframework.boot.context.embedded已将包重新定位到org.springframework.boot.web.server。相应地,EmbeddedServletContainerCustomizer已经改名为WebServerFactoryCustomizer。
例如,如果您使用TomcatEmbeddedServletContainerFactory回调接口自定义嵌入式Tomcat容器,则现在应该使用TomcatServletWebServerFactory,如果您使用的是EmbeddedServletContainerCustomizerbean,则现在应该使用WebServerFactoryCustomizer<TomcatServletWebServerFactory>bean。
特定于Servlet的服务器属性
许多server.*特定于Servlet 的属性已移至server.servlet:
server.context-parameters.* 转到server.servlet.context-parameters.*
server.context-path转到server.servlet.context-path
server.jsp.class-name转到server.servlet.jsp.class-name
server.jsp.init-parameters.*转到server.servlet.jsp.init-parameters.*
server.jsp.registered转到server.servlet.jsp.registered
server.servlet-path转到server.servlet.path
Web Starter作为传递依赖
以前有几个Spring Boot启动器在传输上依赖于Spring MVC spring-boot-starter-web。有了Spring WebFlux的新支持spring-boot-starter-mustache,spring-boot-starter-freemarker并且spring-boot-starter-thymeleaf不再依赖它了。开发人员有责任选择和添加spring-boot-starter-web或spring-boot-starter-webflux。
模板引擎
Thymeleaf
Thymeleaf首发包括thymeleaf-layout-dialect以前的依赖。由于Thymeleaf 3.0现在提供[实现布局的本地方式](https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#template-layout),我们删除了强制依赖,并将此选择留给您。如果您的应用程序依赖于该layout-dialect项目,请将其明确添加为依赖项。
Mustache Templates 默认文件扩展名
Mustache模板的默认文件扩展名是.html,它现在.mustache与官方规范和大多数IDE插件一致。您可以通过更改spring.mustache.suffix配置键来覆盖此新默认值。
Jackson / JSON 支持
在2.0中,我们将Jackson配置默认设置为将JSR-310日期写为ISO-8601字符串。如果要返回先前的行为,可以添加spring.jackson.serialization.write-dates-as-timestamps=true到配置中。
一个新的spring-boot-starter-json启动器收集必要的位来读写JSON。它不仅提供了jackson-databind与Java8工作时也是有用的模块:jackson-datatype-jdk8,jackson-datatype-jsr310和jackson-module-parameter-names。如果你手动依赖这些模块,你现在可以依赖这个新的启动器。
Spring MVC路径匹配默认行为更改
们决定在Spring MVC应用程序中更改后缀路径匹配的默认值(参见#11105)。根据Spring Framework中记录的最佳实践,默认情况下不再启用此功能。
如果您的应用程序希望将请求\"GET /projects/spring-boot.json\"映射到@GetMapping(\"/projects/spring-boot\")映射,则此更改会影响您。
Servlet过滤器
在是Servlet过滤器的默认调度程序类型DipatcherType.REQUEST; 这使Spring Boot的默认值与Servlet规范的默认值保持一致。如果您希望将过滤器映射到其他调度程序类型,请使用a注册过滤器FilterRegistrationBean。
注意:Spring Security 和Spring Session过滤器配置ASYNC,ERROR以及REQUEST调度类型。
RestTemplateBuilder
该requestFactory(ClientHttpRequestFactory)方法已被新requestFactory(Supplier<ClientHttpRequestFactory> requestFactorySupplier)方法取代。a的使用Supplier允许构建器生成的每个模板使用其自己的请求工厂,从而避免可能由共享工厂引起的副作用。
WebJars定位器
Spring Boot 1.x使用并提供依赖管理org.webjars:webjars-locator。webjars-locator是一个“命名不佳的图书馆......包装webjars-locator-core项目”。org.webjars:webjars-locator应该更新依赖关系以使用org.webjars:webjars-locator-core。
Security
Spring Boot 2大大简化了默认的安全配置,使添加自定义安全性变得简单。Spring Boot现在只有一个添加自己的行为后退,而不是有几个与安全相关的自动配置WebSecurityConfigurerAdapter。
如果您使用以下任何属性,则会受到影响:
默认安全性
安全自动配置不再公开选项,并尽可能使用Spring Security默认值。其中一个明显的副作用是使用Spring Security的内容协商进行授权(表单登录)。
默认用户
默认情况下,Spring Boot使用生成的密码为单个用户配置。可以使用下的属性配置用户spring.security.user.*。要进一步自定义用户或添加其他用户,您将不得不公开UserDetailsServicebean。
此示例演示了如何执行此操作。
要禁用默认用户创建,请提供类型为的bean AuthenticationManager,AuthenticationProvider或UserDetailsService。
AuthenticationManager Bean
如果要将Spring Security AuthenticationManager作为bean 公开,请覆盖authenticationManagerBean您的方法WebSecurityConfigurerAdapter并使用它进行注释@Bean。
OAuth2
从功能的Spring Security OAuth的项目被迁移到核心Spring Security的。不再为该依赖项提供依赖关系管理,Spring Boot 2 通过Spring Security 5 提供OAuth 2.0客户端支持。
如果您依赖尚未迁移的Spring Security OAuth功能,则需要在其他jar上添加依赖项,请查看文档以获取更多详细信息。我们还将继续支持Spring Boot 1.5,因此较旧的应用程序可以继续使用它,直到提供升级路径。
执行器安全
Actuator不再有单独的安全自动配置(management.security.*属性消失)。sensitive每个端点的标志也在安全配置中更明确。如果您依赖于此行为,则需要创建或调整安全配置以使用您选择的角色来保护端点。
例如,假设以下配置
需要注意的是在2.x,health并且info在默认情况下启用(与health默认情况下不显示其细节)。为了与这些新默认值保持一致,health已添加到第一个匹配器中。
使用SQL数据库
Spring Data Kay 重命名了许多CRUD存储库方法。调用重命名方法的应用程序代码必须更新。为了简化迁移,您可能需要考虑使用自定义CrudRepository子接口来声明不推荐使用旧名称的默认方法,并委托给等效的新命名方法。标记默认方法已弃用将有助于确保不会忘记迁移。
配置数据源
默认连接池已从Tomcat切换到HikariCP。如果您曾经spring.datasource.type在基于Tomcat的应用程序中强制使用Hikari,则现在可以删除该覆盖。
特别是,如果你有这样的设置:
您现在可以用以下内容替换它:
警告暗示'开放视图'的消息
现在开始,未明确启用的应用程序spring.jpa.open-in-view将在启动期间收到WARN消息。虽然此行为是友好的默认设置,但如果您不完全了解为您做什么,这可能会导致问题。此消息确保您了解可以在视图呈现期间执行数据库查询。如果你没问题,可以明确配置此属性以使警告消息静音。
JPA
在Spring Boot 1.x中,一些用户正在扩展HibernateJpaAutoConfiguration以将高级自定义应用于自动配置EntityManagerFactory。为了防止这种错误的用例发生,不再可能在Spring Boot 2中扩展它。
为了支持这些用例,您现在可以定义一个HibernatePropertiesCustomizerbean,它可以让您完全控制Hibernate属性,包括在上下文中注册声明为bean的Hibernate拦截器的能力。
Id生成器
spring.jpa.hibernate.use-new-id-generator-mappings现在true,该属性默认与Hibernate的默认行为一致。如果需要暂时还原此现已弃用的行为,请将该属性设置为false。
Flyway
Flyway配置键被移动到spring命名空间(即spring.flyway)
升级到Spring启动2将升级迁飞3.x到5.x。要确保架构升级顺利进行,请按照以下说明操作:
首先将1.5.xSpring Boot应用程序升级到Flyway 4(4.2.0在撰写本文时),请参阅Maven和Gradle的说明。
将架构升级到Flyway 4后,升级到Spring Boot 2并再次运行迁移,将应用程序移植到Flyway 5。
Liquibase
Liquibase配置键被移动到spring命名空间(即spring.liquibase)
数据库初始化
DataSource现在,只对嵌入式数据源启用基本初始化,并在使用生产数据库时立即关闭。新的spring.datasource.initialization-mode(替换spring.datasource.initialize)提供更多的控制。
更新了默认的'create-drop'处理
仅当未使用Liquibase或Flyway等架构管理器时,该spring.jpa.hibernate.ddl-auto属性create-drop才会默认使用嵌入式数据库。一旦检测到架构管理器,默认值就会更改为none。
使用NoSQL Technologies
Redis
当您使用时,现在使用Lettuce代替Jedis作为Redis驱动程序spring-boot-starter-data-redis。如果您使用更高级别的Spring Data构造,则应该发现更改是透明的。
我们仍然支持Jedis。如果您喜欢通过排除io.lettuce:lettuce-core和添加Jedis来切换依赖关系redis.clients:jedis。
Elasticsearch
Elasticsearch已升级到5.4+。根据Elastic宣布不再支持嵌入式Elasticsearch,NodeClient已删除a的自动配置。TransportClient可以通过使用spring.data.elasticsearch.cluster-nodes提供要连接的一个或多个节点的地址来自动配置A.
高速缓存
用于缓存的专用Hazelcast自动配置
不再可以自动配置常规HazelcastInstance和专用HazelcastInstance缓存。因此,该spring.cache.hazelcast.config物业不再可用。
批量
将CommandLineRunner在启动的时候执行的批处理作业为0的顺序。
测试
Mockito 1.x
1.x的的Mockito不再支持的@MockBean和@SpyBean。如果您不使用spring-boot-starter-test管理依赖项,则应升级到Mockito 2.x.
Mockito 2中的新功能
创建自己的自动配置
ConditionalOnBean语义更改
ConditionalOnBean现在使用逻辑AND而不是OR候选bean。如果您需要保留存在任何目标bean的条件,请考虑使用AnyNestedCondition以下示例中所示的a :
Spring Boot 启动器
Spring Boot 2对执行器(内部和面向用户)进行了重要更改
请查看参考指南中的更新部分和新的Actuator API文档。
您应该期望编程模型,配置键和某些端点的响应格式发生变化。现在,Spring MVC,Spring WebFlux和Jersey本身支持Actuator。
建立
执行器的代码分为两个模块:现有模块spring-boot-actuator和新模块spring-boot-actuator-autoconfigure。如果您使用原始模块(spring-boot-actuator)导入执行器,请考虑使用spring-boot-starter-actuator启动器。
配置键结构
终端基础设施密钥已经统一:
endpoints.<id>.*到management.endpoint.<id>.*
endpoints.cors.*到management.endpoints.web.cors.*
endpoints.jmx.*到management.endpoints.jmx.*
management.address到management.server.address
management.context-path到management.server.servlet.context-path
management.ssl.*到management.server.ssl.*
management.port到management.server.port
基本路径
/actuator默认情况下,所有端点都已移至。
我们修改了management.server.servlet.context-path它的含义:它现在是端点管理的等价物server.servlet.context-path(仅在management.server.port设置时有效)。此外,您还可以使用新的单独属性设置管理端点的基本路径:management.endpoints.web.base-path。
例如,如果你设置management.server.servlet.context-path=/management和management.endpoints.web.base-path=/application,你就可以在下面的路径到达终点健康:/management/application/health。
如果要恢复1.x的行为(即/health代替/actuator/health),请设置以下属性:
审核事件API更改
AuditEventRepository 现在有一个带有所有可选参数的方法。
端点
要通过HTTP提供执行器端点,需要同时启用和公开。默认:
无论应用程序中是否存在和配置Spring Security,都只显示/health和/info端点。
所有端点但/shutdown都已启用。
您可以按如下方式公开所有端点:
您可以使用以下命令显式启用/shutdown端点:
要公开除端点之外的所有(已启用)Web env端点:
表1.端点更改
/actuator
不再可用。但是,根目录中有一个映射,management.endpoints.web.base-path它提供了指向所有暴露端点的链接。
/auditevents
after不再需要该参数
/autoconfig
改名为 /conditions
/docs
不再可用(API文档现在是已发布文档的一部分)
/health
而不是依靠sensitive标志弄清楚如果health端点必须证明全部细节或没有,现在有一个management.endpoint.health.show-details选项:never,always,when-authorized。默认情况下,/actuator/health公开并且不显示详细信息。
/trace
改名为 /httptrace
端点属性已更改如下:
endpoints.<id>.enabled 已经搬到了 management.endpoint.<id>.enabled
endpoints.<id>.id 没有替换(端点的id不再可配置)
endpoints.<id>.sensitive没有替代品(参见执行器安全性)
endpoints.<id>.path 已经搬到了 management.endpoints.web.path-mapping.<id>
端点格式
检修“/执行器/映射”执行器端点
JSON格式已更改为现在正确包含有关上下文层次结构,多个DispatcherServlets,已部署的Servlet和Servlet过滤器的信息。
有关详细信息,请参阅#9979。
Actuator API文档的相关部分提供了示例文档。
“/ actuator / httptrace”执行器端点的大修
响应的结构已经过细化,以反映端点对跟踪HTTP请求 - 响应交换的关注。
迁移自定义端点
如果您有自定义执行器端点,请查看专门的博客文章。该团队还编写了一个wiki页面,描述了如何将现有的Actuator端点迁移到新的基础架构。
Metrics
Spring Boot自己的指标已被替换为支持,包括自动配置,Micrometer和维度指标。
设置Micrometer
如果您的Spring Boot 2.0应用程序已经依赖于Actuator,Micrometer已经在这里并自动配置。如果您希望将指标导出到Prometheus,Atlas或Datadog等外部注册表,Micrometer会为许多注册表提供依赖关系; 然后,您可以使用spring.metrics.*属性配置应用程序以导出到特定注册表。
迁移自定义Counters/Gauges
您可以通过以下方式创建各种指标,而不是在应用程序代码中注入CounterService或GaugeService实例:
MeterRegistry在其上注入和调用方法。
直接调用静态方法Counter featureCounter = Metrics.counter(\"feature\");。
Spring Boot 1.5支持
您可以使用Micrometer Legacy支持在同一指标基础架构中插入现有的Spring Boot 1.5应用程序。
开发者工具
Developer Tools
由于Spring Loaded项目已移至阁楼,因此它在Spring Boot中的支持已被删除。我们建议改用Devtools。
Devtools远程调试隧道
已经从Devtools中删除了对通过HTTP进行隧道远程调试的支持。
删除功能
以下功能不再可用:
CRaSH支持
Spring Mobile的自动配置和依赖关系管理。
Spring Social的自动配置和依赖管理。请查看Spring Social项目以获取更多详细信息。
依赖管理commons-digester。
CLI中的测试支持(即spring test)
依赖版本
以下库的最低支持版本已更改:
Elasticsearch 5.6
Gradle 4
Hibernate 5.2
Jetty 9.4
Spring Framework 5
Spring Security 5
Spring Integration 5(另请参阅他们的迁移指南)
Tomcat 8.5
Spring boot 2.0(2018 年 03 月)
如果您当前正在使用早期版本的Spring Boot,我们强烈建议您在迁移到Spring Boot 2.0之前升级到Spring Boot 1.5。
Java 8 Baseline和Java 9支持
Spring Boot 2.0需要Java 8作为最低版本。许多现有的API已经更新,以利用Java 8的功能,例如:接口上的默认方法,功能回调和新的API,如javax.time。如果您当前使用的是Java 7或更早版本,那么在开发Spring Boot 2.0应用程序之前,您需要升级JDK。
Spring Boot 2.0也运行良好,并且已经过JDK 9的测试。我们所有的jar都在模块系统兼容性的清单中附带自动模块名称条目。
第三方Library升级
Spring Boot 2.0构建并需要Spring Framework 5.您可能希望了解Spring Framework 5.0中可用的新功能,并在继续之前查看其升级指南。
我们已尽可能升级到其他第三方罐子的最新稳定版本。此版本中的一些值得注意的依赖项升级包括:
Flyway 5
Reactive Spring
Spring产品组合中的许多项目现在都为开发反应式应用程序提供了一流的支持。反应式应用程序完全异步且无阻塞。它们旨在用于事件循环执行模型(而不是更传统的一个每请求线程执行模型)。Spring Framework参考文档中的“Web on Reactive Stack”部分为该主题提供了出色的入门读物。
Spring Boot 2.0通过自动配置和starter-POM完全支持反应式应用程序。Spring Boot本身的内部也在必要时进行了更新,以提供反应性的alernative(最明显的是我们的嵌入式服务器支持)。
Spring WebFlux和WebFlux.fn
Spring WebFlux是一种完全无阻塞的Spring MVC替代方案。Spring Boot为基于注释的Spring WebFlux应用程序以及提供更多功能样式API的WebFlux.fn提供自动配置。
首先,使用spring-boot-starter-webflux启动POM,它将提供由嵌入式Netty服务器支持的Spring WebFlux。
Reactive Spring Data
在底层技术支持的情况下,Spring Data还为响应式应用程序提供支持。目前Cassandra,MongoDB,Couchbase和Redis都有反应API支持。
Spring Boot包含针对这些技术的特殊入门级POM,可提供入门所需的一切。例如,spring-boot-starter-data-mongodb-reactive包括对响应式mongo驱动程序和项目反应器的依赖性。
Reactive Spring Security
Spring Boot 2.0可以利用Spring Security 5.0保护您的被动应用程序。只要Spring Security位于类路径上,就会为WebFlux应用程序提供自动配置。
可以通过a配置Spring Security with WebFlux的访问规则SecurityWebFilterChain。如果您以前使用Spring Security与Spring MVC,那应该会非常熟悉。
嵌入式Netty Server
由于WebFlux不依赖于Servlet API,我们现在能够首次支持Netty作为嵌入式服务器。该spring-boot-starter-webflux起动POM将拉Netty中4.1和Ractor Netty的。
HTTP / 2支持
为Tomcat,Undertow和Jetty提供HTTP / 2支持。支持取决于所选的Web服务器和应用程序环境(因为JDK 8不支持该协议)。
配置属性绑定
用于绑定Environment属性的机制@ConfigurationProperties已经在Spring Boot 2.0中彻底改进。我们借此机会收紧了轻松绑定的规则,并修复了Spring Boot 1.x中的许多不一致问题。
新BinderAPI也可以@ConfigurationProperties直接在您自己的代码中使用。例如,下面将结合到List的PersonName对象:
配置源可以用YAML表示,如下所示:
Property Origins
Spring Boot加载的YAML文件和属性文件现在包含的Origin信息可以帮助您跟踪项目的加载位置。有几个Spring Boot功能可以利用这些信息并在适当的时候显示它。
例如,BindException绑定失败时抛出的类是OriginProvider。这意味着可以从故障分析器很好地显示原始信息。
另一个例子是env执行器端点,它包括可用时的原始信息。下面的代码段显示该spring.security.user.name属性来自jar中打包的文件的line 1,column :27application.properties
Converter 支持
绑定使用了一个新ApplicationConversionService类,它提供了一些额外的转换器,这些转换器对于属性绑定特别有用。最值得注意的是Duration类型和分隔字符串的转换器。
该Duration转换器允许在任一ISO-8601格式中指定的持续时间,或作为一个简单的字符串(例如10m,10分钟)。现有属性已更改为始终使用Duration。该@DurationUnit注释通过设置如果没有指定所使用的单元确保向后兼容性。例如,Spring Boot 1.5中预期秒数的属性现在必须@DurationUnit(ChronoUnit.SECONDS)确保一个简单的值,例如10实际使用10s。
定界字符串转换允许您将简单绑定String到Collection或Array不必在逗号上拆分。例如,LDAP base-dn属性的使用@Delimiter(Delimiter.NONE)使得LDAP DN(通常包括逗号)不会被误解释。
Gradle插件
Spring Boot的Gradle插件已经在很大程度上被重写,以实现许多重大改进。您可以在其参考和api文档中阅读有关插件功能的更多信息。
Spring Boot现在需要Gradle 4.x. 如果要升级使用Gradle的项目
Kotlin
Spring Boot 2.0现在包含对Kotlin 1.2.x的支持,并提供了一种runApplication功能,它提供了一种使用惯用Kotlin运行Spring Boot应用程序的方法。我们还公开并利用了其他Spring项目(如Spring Framework,Spring Data和Reactor)添加到其最新版本中的Kotlin支持。
Actuator 改进
Spring Boot 2.0对执行器端点进行了许多改进和改进。现在,所有HTTP执行器端点都在/actuator路径下公开,并且所得到的JSON有效负载已得到改进。
我们现在也默认不暴露这么多端点。如果您要升级现有的Spring Boot 1.5应用程序,请务必查看迁移指南并特别注意该management.endpoints.web.exposure.include属性。
Actuator JSON
Spring Boot 2.0改进了从许多端点返回的JSON有效负载。
现在,许多端点都具有更准确地反映基础数据的JSON。例如,/actuator/conditions端点(/autoconfig在Spring Boot 1.5中)现在有一个顶级contexts键来对结果进行分组ApplicationContext。
现在还使用Spring REST Docs生成了大量REST API 文档,并随每个版本一起发布。
Jersey和WebFlux支持
除了Spring MVC和JMX支持之外,您现在可以在开发纯Jersey或WebFlux应用程序时访问执行器端点。Jersey支持是通过自定义Jersey提供的Resource,WebFlux使用自定义HandlerMapping。
超媒体链接
该/actuator端点现在提供了一个HAL格式的响应提供链接到所有活动端点(即使你没有春天HATEOAS在classpath)。
Actuator @Endpoints
为了支持Spring MVC,JMX,WebFlux和Jersey,我们开发了一种新的执行器端点编程模型。该@Endpoint批注可以与组合使用@ReadOperation,@WriteOperation并@DeleteOperation制定一个技术无关的方式端点。
您还可以使用@EndpointWebExtension或@EndpointJmxExtension编写端点的技术特定增强功能。
Micrometer
Spring Boot 2.0不再附带自己的度量标准API。相反,我们依靠micrometer.io来满足所有应用程序监控需求。
Micrometer包括对尺寸度量的支持,当与尺寸监视系统配对时,允许有效访问特定命名度量,并能够在其维度上向下钻取。
度量标准可以导出到各种系统,开箱即用的Spring Boot 2.0支持Atlas,Datadog,Ganglia,Graphite,Influx,JMX,New Relic,Prometheus,SignalFx,StatsD和Wavefront。此外,还可以使用简单的内存中度量标准。
集成提供了JVM指标(包括CPU,内存,线程和GC),Logback,Tomcat,Spring MVC和RestTemplate。
Data 支持
此外,上面提到的“Reactive Spring Data”支持,还在Data领域进行了其他一些更新和改进。
HikariCP
pring Boot 2.0中的默认数据库池技术已从Tomcat Pool切换到HikariCP。我们发现Hakari提供了卓越的性能,我们的许多用户比Tomcat Pool更喜欢它。
初始化
数据库初始化逻辑已在Spring Boot 2.0中合理化。Spring Batch,Spring Integration,Spring Session和Quartz的初始化现在默认情况下仅在使用和嵌入式数据库时发生。该enabled物业已被更具表现力的枚举所取代。例如,如果要始终执行Spring Batch初始化,则可以进行设置spring.batch.initialize-schema=always。
如果Flyway或Liquibase正在管理您的DataSource的架构并且您正在使用嵌入式数据库,Spring Boot现在将自动关闭Hibernate的自动DDL功能。
JOOQ
Spring Boot 2.0现在可以根据DataSource自动检测jOOQ方言(类似于JPA方言所做的)。@JooqTest还引入了一个新的注释来简化测试,只需要使用jOOQ。
JdbcTemplate
在JdbcTemplate那个Spring Boot 自动配置就现在可以通过定制化的spring.jdbc.template特性。此外,NamedParameterJdbcTemplate自动配置的重用JdbcTemplate在幕后。
Spring Data Web配置
Spring Boot公开了一个新的spring.data.web配置命名空间,可以轻松配置分页和排序。
Influx DB
Spring Boot现在自动配置开源时间序列数据库InfluxDB。要启用InfluxDB支持,您需要设置spring.influx.url属性,并influxdb-java在类路径中包含。
Flyway / Liquibase灵活配置
如果仅提供自定义url或user属性,则Flyway和Liquibase的自动配置现在重用标准数据源属性而不是忽略它们。这允许您DataSource仅使用所需信息为迁移目的创建自定义。
Hibernate
现在支持自定义Hibernate命名策略。对于高级方案,您现在可以在上下文中定义ImplicitNamingStrategy或PhysicalNamingStrategy用作常规bean。
现在也可以通过暴露HibernatePropertiesCustomizerbean 来定制Hibernate以更细粒度的方式使用的属性。
MongoDB 客户端自定义
现在可以通过定义类型的bean将高级自定义应用于Spring Boot自动配置的Mongo客户端MongoClientSettingsBuilderCustomizer。
现在可以使用spring.cache.redis.*属性配置Redis的缓存默认值。
Web
除了上面提到的WebFlux和WebFlux.fn支持之外,还进行了以下改进以帮助开发Web应用程序。
上下文路径记录
使用嵌入式容器时,应用程序启动时会在HTTP端口旁记录上下文路径。举个例子,嵌入式Tomcat现在看起来像这样:
Web过滤器初始化
现在,Web过滤器已在所有受支持的容器上急切地初始化。
Thymeleaf启动器现在包括thymeleaf-extras-java8time为javax.time类型提供支持。
JSON支持
一个新的spring-boot-starter-json启动器收集必要的位来读写JSON。它不仅提供了jackson-databind与Java8工作时,也是有用的模块:jackson-datatype-jdk8,jackson-datatype-jsr310和jackson-module-parameter-names。这个新的启动器现在用于jackson-databind以前定义的地方。
如果您更喜欢Jackson之外的其他东西,我们在Spring Boot 2.0中对GSON的支持已大大改善。我们还引入了对JSON-B的支持(包括JSON-B测试支持)。
Quartz
现在包括Quartz Scheduler的自动配置支持。我们还添加了一个新的spring-boot-starter-quartz启动器POM。
您可以使用内存JobStores或完整的基于JDBC的存储。所有JobDetail,Calendar并Trigger从你的Spring应用程序上下文豆将自动注册Scheduler。
对Spring Boot 2.0中提供的测试支持进行了一些补充和调整:
@WebFluxTest添加了一个新的注释来支持WebFlux应用程序的“切片”测试。
Converter和GenericConverter豆类现在自动扫描@WebMvcTest和@WebFluxTest。
@AutoConfigureWebTestClient添加了一个注释以提供WebTestClient要使用的测试的bean。注释会自动应用于@WebFluxTest测试。
添加了一个新的ApplicationContextRunner测试实用程序,可以非常轻松地测试您的自动配置。我们已将大部分内部测试套件移至此新模型。
除了上面列出的变化之外,还有许多小的调整和改进,包括:
@ConditionalOnBean现在,在确定是否满足条件时,使用逻辑AND而不是逻辑OR。
无条件类现在包含在自动配置报告中。
该springCLI应用程序现在包括encodepassword可用于创建Spring Security的兼容散列密码命令。
@EnableScheduling可以使用scheduledtasks执行器端点来查看计划任务(即)。
该loggers驱动器终端现在允许你重新设置一个记录器级别为它的默认。
Spring Session用户现在可以通过sessions执行器端点查找和删除会话。
spring-boot-starter-parent现在使用的基于Maven的应用程序-parameters默认使用该标志。
我们的构建现在使用Concourse for CI,我们的项目POM文件已经过重构,因此它们更简单(这些更改对于大多数用户应该是透明的,但如果您发现已发布的POM有任何问题,请报告它们)。
Animated ASCII Art
最后,为了好玩,Spring Boot 2.0现在支持动画GIF横幅。
v0.5.0.M1(2013-08-06)
Spring Boot 1.0(2014 年 4 月)
Spring boot 1.1(2014 年 6 月)
从Spring Boot 1.0升级注意事项
测试依赖性
该spring-boot-starter-testPOM不再自动列入spring-boot-starter-parent。将默认测试依赖项添加到父POM似乎是个好主意,遗憾的是它们无法轻易更改或删除。
从1.0升级时,请务必添加依赖项spring-boot-starter-test。
Redis驱动程序
Spring Boot 1.0使用了Lettuce Redis驱动程序。Spring Boot 1.1改为使用Jedis驱动程序。对大多数用户而言,此更改应该是透明的
HealthIndicators
该HealthIndicator接口已经改变为具有更明确的API:现在总是返回一个Health具有可定制的实例Status以及额外的上下文信息。Health从所有HealthIndicators注册的实例返回的实例ApplicationContext将由新引入的接口的实现聚合HealthAggregator。默认HealthAggregator实现具有所有内置Status类型的优先级顺序,例如Status.UP,Status.DOWN或Status.OUT_OF_SERVICE。可以配置和扩展订单以支持新引入的自定义Status代码。
/health现在可以将MVC端点配置为为不同的Status代码返回不同的HTTP状态代码。默认情况下Status.DOWN会创建503; Status.UP将返回200. 也可以配置和扩展映射Status到HttpStatus,以满足您的需求。
该SimpleHealthIndicator班已更名为DataSourceHealthIndicator。此外,我们还为Mongo,Redis,Rabbit和Apache Solr添加了基本的健康检查支持。使用Spring Boot Actuator时,如果自动检测到数据存储或消息传递系统,将自动添加这些运行状况检查。当然可以禁用健康检查的创建。
JMS更改
该JmsTemplate级现在默认pubSubDomain来false,而不是true。该JmsTemplateAutoConfiguration班已更名为JmsAutoConfiguration。在ActiveMQAutoConfiguration类现在是在一个activemq子包。
ErrorController
该ErrorController接口及相关类已经从移动spring-boot-actuator到spring-boot-autoconfigure。对于大多数用户而言,此更改应该是透明的,但是,已发生某些包重命名。
多部分配置
在MultiPartConfigFactory已经更名为MultipartConfigFactory(注意不同的情况下)。
Spring Data自动配置包
Spring Data自动配置类已移至子包。大多数用户不会直接使用它们,但如果您通过@EnableAutoConfiguration exclude属性引用它们,则可能需要更改导入。
反应堆
Spring Boot现在默认提供Reactor 1.1.2(1.0.x提供了Reactor 1.0.1)。在Reactor 1.1中,reactor-tcp模块已重命名reactor-net。如果您正在使用reactor-tcp,则应更新您的依赖项以使用reactor-net。
使用Maven运行您的应用程序
Spring Boot现在分叉运行你的应用程序(即使用mvn spring-boot:run)。这具体意味着命令行参数不再可用于应用程序。查看此示例以获取更多详细信息
额外的模板支持
现在支持Freemarker,Groovy和Velocity模板以及现有的Thymeleaf和JSP支持。
系统端点的监控
该/metrics驱动器的端点现在包括更多信息,包括堆细节,类负载数,线程信息和垃圾收集的统计数据。
对maven插件的支持
对Gradle插件的支持
自定义banner
您现在可以通过向banner.txt类路径添加文件或通过设置banner.location属性来添加自定义横幅。
Flyway数据库迁移
现在为Flyway数据库迁移提供了自动配置。
Liquibase数据库迁移
现在为Liquibase数据库迁移提供了自动配置。
Mongo
自动配置进行了改进,使您现在可以注入Mongo,MongoDbFactory或MongoTemplate豆类。还通过自动配置的GridFsTemplatebean 添加了GridFS支持。
GemFire
一个新spring-boot-starter-data-gemfire模块可用于Spring Data GemFire支持。
HornetQ
现在可以为HornetQ JMS代理提供自动配置支持,以及新的spring-boot-starter-hornetq启动POM。如果org.hornetq:hornetq-jms-server在类路径中可用,则默认情况下会自动配置嵌入式HornetQ代理。
现在可以为Elasticseach提供自动配置支持,以及新的spring-boot-starter-data-elasticsearch启动器POM。
Apache Solr
现在,Apache Solr可以使用自动配置支持以及新的spring-boot-starter-data-solr启动器POM。
网站改进
Spring HATEOAS'' and Spring Data Rest MVC的自动配置类现已添加到Spring Boot中。多部分文件上载支持已更改为默认启用。
Spring Social
自动配置现在可用于Spring Social的Facebook,Twitter和LinkedIn连接器。
Spring Mobile
Spring Mobile自动配置已更新,包括支持SitePreferenceHandler。
Spring集成
为Spring Integration添加了自动配置。如果Spring Integration在您的类路径上,您现在将自动获得@EnableIntegration一些Spring Integration JMX bean。
Spring-WS
一个新spring-boot-starter-ws的可用于Spring Web Services支持。
Jackson
对Jackson JSON编组库的支持已得到改进。现在,您将获得杰克逊的自动配置豆类ObjectMapper以及JodaModule和JSR310Module在适当的时候支持。您现在还可以添加自己的Modulebean并自动应用它们。
HikariDataSource
已为Hikari连接池库添加了支持。只需确保HikariCP库位于类路径中,而不是Tomcat DBCP。
新的条件注释
@ConditionalSpring Boot 1.1中添加了两个新注释。@ConditionalOnProperty支持根据Environment属性的存在有条件地启用bean ,@ConditionalOnJava并可用于基于JVM版本启用Bean。
Spring Boot 1.2(2015 年 3 月)
从Spring Boot 1.1升级注意事项
Servlet 3.1,Tomcat 8和Jetty 9
Spring Boot现在使用Tomcat 8和Jetty 9作为嵌入式servlet容器。这提供了开箱即用的Servlet 3.1和增强的WebSocket支持。如果您希望坚持使用旧版本,仍然可以使用Tomcat 7或Jetty 8。
记录输出
使用Spring Boot 1.2更新了默认日志记录配置,不再写入日志文件。如果需要文件输出,可以使用logging.path或logging.file属性。您还可以通过添加自己的logback.xml文件来完全自定义日志记录。
一致的HTTP URI /正文解码
CharacterEncodingFilter现在自动注册A 以进行一致的URI /正文解码。
spring.http.encoding.charset如果您不需要注册,则可以使用该属性,如果您不需要注册,则可以UTF-8设置spring.http.encoding.enabled为false CharacterEncodingFilter。
使用Spring MVC的IgnoreDefaultModelOnRedirect
Spring MVC自动配置现在默认设置ignoreDefaultModelOnRedirect为RequestMappingHandlerAdapterto 的属性true。
如果您需要将模型属性作为重定向网址的一部分,则可以将以下内容添加到application.properties:
spring.mvc.ignore-default-model-on-redirect=false
Jackson defaults
自动配置的Jackson ObjectMapper现在拥有MapperFeature.DEFAULT_VIEW_INCLUSION并 DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES禁用。
如果您需要恢复到之前的设置,可以将以下内容添加到application.properties:
spring.jackson.mapper.default-view-inclusion=true
spring.jackson.deserialization.fail-on-unknown-properties=true
Mongo and MongoDbFactory Beans
如果定义自己的bean ,MongoAutoConfiguration该类将不再注册bean。确保在声明自己的bean时注册bean,或者只使用接口访问Mongo数据库。
MongoMongoDbFactoryMongoMongoDbFactoryMongoDbFactory
Moved health.* properties to management.health.*
Health-related 配置密钥已从中移除,health以management.health与其他与管理相关的属性保持一致。
更名为VanillaHealthIndicator类
该VanillaHealthIndicator班已更名为ApplicationHealthIndicator。
大多数用户不会直接与该类进行交互,但是,如果您以前org.springframework.boot.actuate.health.VanillaHealthIndicator在代码中导入,则需要将其更改为
org.springframework.boot.actuate.health.ApplicationHealthIndicator。
该SpringNamingStrategy班已经搬到了org.springframework.boot.orm.jpa.hibernate包。旧的org.springframework.boot.orm.jpa.SpringNamingStrategy遗骸但已弃用,将在以后的版本中删除。
现在提供托管依赖项hibernate-envers,hibernate-jpamodelgen和hibernate-ehcache。
Health JSON
/health当只HealthIndicator涉及一个时,执行器端点JSON略有修改。如果您之前查询过特定的JSON路径,则可能需要更新任何监视工具。
匿名健康访问限制
该/health驱动器现在端点限制匿名访问。匿名访问时,端点会隐藏健康详细信息,只是指示服务器是否为UP或DOWN。它还缓存了指定时间段内的响应endpoints.health.time-to-live。可以禁用这些限制,从而通过设置endpoints.health.sensitive来恢复1.1.x的行为false。
Spring 4.1
Spring Boot 1.2需要Spring Framework 4.1.5或更高版本,并且与Spring Framework 4.0不兼容。
Hikari CP
com.zaxxer:HikariCPBoot的依赖管理提供的版本现在需要Java 8.如果您在Java 6或Java 7上运行,则应该更新您的依赖项以使用它com.zaxxer:HikariCP-java6。
Configuration Properties
该物业spring.data.mongo.repositories.enabled已更名为spring.data.mongodb.repositories.enabled。
弃用
该org.springframework.boot.actuate.system.ApplicationPidListener课程已被取代ApplicationPidFileWriter
该CLI @EnableRabbitMessaging注解已被取代@EnableRabbit从spring-rabbit项目。
不推荐使用这些属性以支持它们的等价物。http.mappers.spring.jackson.serialization.
org.springframework.boot.json.SimpleJsonParser已被弃用,BasicJsonParser以避免与“JSON Simple”库混淆。
版本更新
Spring Boot 1.2构建于Spring Framework 4.1之上并需要它。此版本已经升级了几个第三方依赖项,包括Jackson,Joda Time和Hibernate Validator。Tomcat 8和Jetty 9现在是默认的嵌入式servlet容器(提供Servlet 3.1支持)。
@SpringBootApplication注释
添加了一个新的@SpringBootApplication便利注释,相当于@Configuration+ @EnableAutoConfiguration+ @ComponentScan。如果您发现经常使用这三个注释,您可能需要考虑交换。
JTA支持
Spring Boot 1.2现在支持使用Atomkos或Bitronix嵌入式事务管理器跨多个XA资源的分布式JTA事务。部署到合适的Java EE Application Server时,也支持JTA事务。
当检测到JTA环境时,Spring JtaTransactionManager将用于管理事务。自动配置的JMS,DataSource和JPA bean将升级为支持XA事务。您可以使用标准的Spring惯用语@Transactional来参与分布式事务。
此外,提供了一般支持类,使Atomkos和Bitronix更易于配置,即使您不使用@EnableAutoConfiguration。
JNDI Lookups
如果您使用的是完整的Java EE Application Server,现在可以从JNDI 查找两者DataSource和JMS ConnectionFactorybean。使用您或文件中的spring.datasource.jndi-name和spring.jms.jndi-name属性。application.propertiesapplication.yml
Jackson customization
现在可以使用属性自定义JacksonObjectMapperspring.jackson。杰克逊的SerializationFeature,DeserializationFeature,MapperFeature,JsonParser.Feature和JsonGenerator.Feature对象可以使用自定义serialization,deserialization,mapper,parser和generator属性。
使DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES您能够将以下内容添加到您的application.properties:
此外spring.jackson.date-format,spring.jackson.property-naming-strategySpring Boot 1.2还添加了属性。
Banner Interface
添加了一个新Banner界面,可以与SpringApplication.setBanner(…)提供自定义横幅输出结合使用。使用的src/main/resources/banner.txt仍建议进行简单的横幅,但是,如果你需要做一些花哨的新界面是非常有用的。
Banner Properties
您现在可以使用${application.version},${spring-boot.version},${application.formatted-version}和${spring-boot.formatted-version}在你的变量src/main/resources/banner.txt文件打印您的应用程序版本和/或弹簧引导的版本。该formatted-version被包围在括号并且包括v前缀,例如,(v1.2.0.RELEASE)。
JMS支持
现在为Spring Framework 4.1的@JmsListener注释提供了自动配置。该@EnableJms注释也自动配置,只要你有spring-jms.jar你的类路径中。
AMQP支持
同样,现在为Spring AMQP 1.4的@RabbitListener注释提供了自动配置。该@EnableRabbit注释也自动配置,只要你有spring-rabbit.jar你的类路径中。现有的Rabbit自动配置也已扩展为自动创建RabbitMessagingTemplate。
Spring Cloud Connectors
已添加自动配置,此版本中还包含spring-cloud-connectors新的spring-boot-starter-cloud-connectorsPOM。自动配置提供与@CloudScan注释相同的功能。
Email Support
一个新的spring-boot-starter-mail `starter POM'' has been added along with auto-configuration support. You can inject a `JavaMailSenderbean进入你的服务发送电子邮件。这些spring.mail.*属性可用于自定义SMTP主机等项目。
Undertow嵌入式Servlet容器
除了Tomcat和Jetty之外,Spring Boot现在支持Undertow作为嵌入式Servlet容器。
CLI更新
创建一个新项目
该springCLI命令行工具包括一个新的init,可用于创建从项目的选择start.spring.io。例如,要创建新的Web应用程序,您可以键入:
$ spring init -d=web myapp.zip
CLI扩展
现在可以使用CLI本身安装和卸载CLI扩展。该spring install <maven coordinates>会抢遥控罐子,将其安装到CLI。spring uninstall可用于删除以前安装的扩展。
其他CLI更改
CLI现在可以检测并支持Spring的@Cacheable注释。
Jetty和Tomcat的声明性SSL
现在可以通过设置各种属性以声明方式配置 SSL server.ssl.*。为Tomcat和Jetty提供支持。有关详细信息,请参阅参考文档。
执行器端点
endpoints.enabled添加了全局属性以配置是否应默认启用或禁用端点。这允许您从当前的opt-out'' model to an 选择加入模型中获取权利。例如,要禁用所有端点,除了 health可以使用以下内容application.properties:
endpoints.enabled=false
endpoints.health.enabled=true
系统指标
现在为堆,线程,类和GC信息提供系统度量。
DataSource指标
现在通过/metrics执行器端点公开DataSource池指标。Tomcat,Hikari和Commons DBCP连接池公开了活动连接数和池使用情况详细信息。
Tomcat会话指标
如果您使用Tomcat作为嵌入式servlet容器,则现在会公开活动会话数和最大会话数。
Dropwizard指标
Dropwizard的MetricRegistry项目现在通过/metrics端点自动显示。仪表和计数器反映为单个值。定时器,仪表和直方图扩展为包含Number类型的所有属性的度量标准集。
Health indicators
JSON格式
在/health现在执行端点无论数量返回一致JSON HealthIndicators实际参与。这样可以更轻松地查询特定项目的JSON。
DataSourceHealthIndicator
DataSourceHealthIndicator现在使用该spring.datasource.validation-query属性(如果已设置)来检查数据库的运行状况。
DiskSpaceHealthIndicator
现在,可用磁盘空间被报告为部分或/health指示器,DOWN如果它低于某个阈值(默认为10Mb),将用于触发状态。的health.diskspace.path和health.diskspace.threshold特性可以被用于定制指示器。
Conditions
该@ConditionalOnProperty批注已经更新了新的havingValue和matchIfMissing属性。您现在可以使用条件创建更复杂的属性匹配条件。AnyNestedCondition还添加了一个新类,可用于组成其他类@Conditions。最后,@ConditionalOnBean注释现在支持声明为String属性的类型以及a Class。
GSON支持
现在可以使用GSON而不是Jackson来创建JSON输出。杰克逊仍然是默认和推荐的选择。如果你使用GSON,你应该从你的Maven / Gradle版本中排除Jackson库,除非你使用需要Jackson的Spring Boot的Actuator。从Spring Boot 1.2.2开始,如果Gson和Jackson都在类路径上,您可以通过设置spring.http.converters.preferred-json-mapper将应用程序配置为使用Gson gson。
EmbeddedServerPortWriter
该spring-actuator项目包括一个新org.springframework.boot.actuate.system.EmbeddedServerPortFileWriter类,可用于在应用程序启动时将嵌入式服务器的端口号写入文件。
Log4j2
现在支持Log4J作为备用日志记录系统,并spring-boot-starter-log4j2提供了启动POM。Logback仍然是默认和推荐的日志记录系统。
Jersey auto-configuration
现在为Jersey提供自动配置支持。
Apache-Commons DBCP2支持
commons-dbcp2除了Tomcat,Hikari和DBCP(v1)之外,现在还支持Apache 数据库连接池库。
Maven插件
现在可以禁用该repackage任务spring-boot-maven-plugin。如果你想使用它,这可能很有用,spring-boot:run但你不需要``Fat Jars''。
Configuration meta-data
现在spring-boot,jar spring-boot-autoconfigure和spring-boot-actuatorjar包含其他元数据文件,工具开发人员可以使用这些`code completion'' support in `application.properties文件来提供文件。还提供了注释处理器,允许您从@ConfigurationProperties类自动生成自己的文件。
Spring Boot 1.2还包括以下杂项更新:
该RedisProperties课程现在包括一个database字段。
本RelaxedDataBinder类支持alais的属性。
正则表达式现在可以与所有keystosanitize属性一起使用。
AnsiOutput现在可以使用spring.output.ansi.enabled属性进行配置。
现在,你可以把favicon.ico文件/public,/static,/resources文件夹(旁边其他静态Web资产)。
现在可以使用属性或环境变量指定ApplicationPidFileWriter(先前ApplicationPidListener)写入的文件的位置。spring.pidfilePIDFILE
Tomcat DataSource信息现在通过JMX自动公开。
SpringBootServletInitializer注释的子类@Configuration不再需要重写.configure方法来将自己注册为源。
如果您如此倾向,现在可以使用XML作为application属性格式。
Spring Boot 1.3(2016 年 12 月)
Spring Boot 1.2的弃用
在此版本中已删除Spring Boot 1.2中已弃用的类,方法和属性。请确保在升级之前不要调用已弃用的方法。
Spring Boot 1.2 ObjectMapper在应用程序上下文中注册了所有Jackson Module bean 。这使得无法完全控制ObjectMapperbean的模块。Spring Boot 1.3只会注册ObjectMappers使用自动配置创建或配置的Jackson Module bean Jackson2ObjectMapperBuilder。这使模块配置的行为与Boot的其他Jackson配置保持一致。
Logging
Spring具体配置
为了防止双重初始化,现在可以使用Spring特定的日志配置文件。建议(尽管不是必需的)重命名任何默认日志配置文件以使用-spring后缀。例如,logback.xml将改为logback-spring.xml。
初始化失败
在Spring Boot 1.2中,如果您使用指定了自定义日志记录配置文件logging.config并且该文件不存在,则它将无提示地回退到使用默认配置。由于缺少文件,Spring Boot 1.3失败。同样,如果您提供了格式错误的自定义Logback配置文件,Spring Boot 1.2将回退到其默认配置。Spring Boot 1.3失败并报告配置问题System.err。
Spring HATEOAS
该spring.hateoas.apply-to-primary-object-mapper属性已被删除,因为Spring HATEOAS自动配置已经过重新设计,因此不再影响上下文的主要配置ObjectMapper。它已被一个名为property的属性所取代,该属性spring.hateoas.use-hal-as-default-json-media-type控制Spring HATEOAS HTTP消息转换器是否将处理application/json除请求之外的请求 application/hal+json。
Security for the /health endpoint
执行器/health端点上可见信息的安全设置已稍微调整,以提供更好的一致性。
HTTP响应压缩
Spring Boot 1.2支持Tomcat用户的本机响应压缩,或者使用Jetty的GZipFilter为Jetty,Tomcat和Undertow的用户进行压缩。受Jetty团队弃用gzip过滤器的推动,Spring Boot 1.3取代了这一功能,支持所有三个嵌入式容器中的本机响应压缩。
因此,不再支持和属性。应该使用新属性。
server.tomcat.compression.spring.http.gzip.server.compression.*
Tomcat会话存储
默认情况下,tomcat不再保存会话数据/tmp。如果要与Tomcat一起使用持久会话,请将server.session.persistent属性设置为true。该server.session.store-dir可以用来保存在特定位置的文件。
Jetty JSP
在spring-boot-starter-jetty“入门POM”不再包括org.eclipse.jetty:jetty-jsp。如果您正在使用带有JSP的Jetty,您现在需要自己直接添加此依赖项。
MVC Stacktrace输出
当Spring MVC呈现错误响应时,现在永远不会包含堆栈跟踪信息。如果您希望将Spring Boot 1.2行为设置error.include-stacktrace为on-trace-param。
Thymeleaf的Spring Security集成
由于升级到Spring Security 4,Spring Boot 1.3还升级了Thymeleaf的Spring Security支持的依赖管理和自动配置。新工件的坐标是org.thymeleaf.extras:thymeleaf-extras-springsecurity4。请更新您的pom.xml或build.gradle相应的。
缺少/模板文件夹错误
/templates无法找到文件夹时,Spring Boot应用程序不再无法启动。如果您使用的是受支持的模板技术,并且忘记添加/templates,则会立即记录警告。
Groovy模板
在GroovyTemplateProperties类现在扩展AbstractTemplateViewResolverProperties,并提供额外的配置选项。如果您当前定义了一个prefix.spring.groovy.template.prefix属性来定义自定义资源位置,则应将其重命名为prefix.spring.groovy.resource-loader-location。
自动配置订单
Spring Boot不再尊重@Order管理自动配置类之间的顺序,请@AutoconfigureOrder改用。另请注意,您可以使用@AutoconfigureBefore和@AutoconfigureAfter指定特定自动配置类的顺序。
bootRun资源
使用时,Spring Boot Gradle插件不再src/main/resources直接添加到类路径中bootRun。如果您想要实时的就地编辑,我们建议您使用Devtools。addResources如果要恢复Spring Boot 1.2,可以在gradle构建中设置该属性。行为。
Spring Boot的gradle插件已在此版本中更新,以使用依赖项管理插件。大多数用户不应受此更改的影响,但是那些使用versionManagement配置应用自己的受祝福版本的用户必须更新其构建脚本。
新插件允许您使用Maven bom,而不是要求属性文件来配置版本管理。例如:
应用程序插件
默认情况下,Spring Boot Gradle插件将不再应用Gradle的应用程序插件。如果您希望使用应用程序插件,则必须将其应用于您的应用程序build.gradle。
如果您不需要应用程序插件提供的功能,但是正在使用它mainClassName或applicationDefaultJvmArgs属性,那么您将需要对您的应用程序进行一些小的更新build.gradle。
现在应该使用扩展名mainClass上的属性配置主类springBoot,例如:
applicationDefaultJvmArgs现在应该在项目的ext块中进行配置,例如:
如果使用main应用程序插件run任务的属性配置项目的主类,则应将此配置移至bootRun任务:
spring-boot:运行资源
使用时,Spring Boot Maven插件不再src/main/resources直接添加到类路径中spring-boot:run。如果您想要实时的就地编辑,我们建议您使用Devtools。如果要恢复Spring Boot 1.2,addResources可以在您的属性中设置该属性pom.xml。行为。
Maven资源过滤
如果您使用spring-boot-starter-parent,Maven令牌仅使用@现在过滤。这可以防止配置中的任何Spring占位符(例如$ {foo})被构建扩展。
具体而言,如果您仍在使用标准格式(即${project.version}),请迁移它们(@project.version@)或覆盖maven-resources-plugin配置。
CLI依赖关系管理
Spring Boot 1.3现在支持使用Maven boms来配置其依赖关系管理来代替基于属性文件的元数据。@DependencyManagementBom例如,应该用它来代替@GrabMetadata提供一个bom的坐标@DependencyManagementBom(\"io.spring.platform:platform-bom:1.1.2.RELEASE\")。
以下application.properties键已重命名以提高一致性:
spring.view. 至 spring.mvc.view.
spring.pidfile 至 spring.pid.file
error.path 至 server.error.path
server.session-timeout 至 server.session.timeout
servet.tomcat.accessLogEnabled 至 server.tomcat.accesslog.enabled
servet.tomcat.accessLogPattern 至 server.tomcat.accesslog.pattern
servet.undertow.accessLogDir 至 server.undertow.accesslog.dir
servet.undertow.accessLogEnabled 至 server.undertow.accesslog.enabled
servet.undertow.accessLogPattern 至 server.undertow.accesslog.pattern
spring.oauth2. 至 security.oauth2.
server.tomcat.compression并spring.http.gzip以server.compression.*
prefix.spring.groovy.template.prefix 至 prefix.spring.groovy.resource-loader-location
依赖
Spring 4.2
Spring Boot 1.3需要Spring Framework 4.2或更高版本,并且与早期版本不兼容。
Spring Security 4.0
Spring Boot 1.3使用Spring Security 4.0。
Spring Boot 1.3构建并需要Spring Framework 4.2。此版本已升级了多个第三方依赖项。此版本没有对Tomcat或Jetty版本进行重大升级。
Spring Boot 1.3包含一个spring-boot-devtools旨在改善开发时间体验的新模块。该模块提供:
敏感属性默认值(例如禁用模板缓存)
自动应用程序重启
LiveReload支持
远程开发支持(包括通过HTTP隧道进行远程更新和远程调试)。
重启后的持久HTTP会话
缓存自动配置
现在为以下缓存技术提供自动配置:
EhCache
Hazelcast
Infinispan
Any compliant JCache (JSR 107) implementation
Guava
此外,Map还支持基于简单的内存缓存。在使用@Configuration注释应用程序时自动配置缓存@EnableCaching。缓存统计信息现在也作为执行器端点公开(当底层技术允许时)。
完全可执行的JAR和服务支持
Spring Boot Maven和Gradle插件现在可以为Linux / Unix操作系统生成完整的可执行存档。此外,您现在可以轻松地将这些JAR安装为服务init.d或systemd服务。运行完全可执行的JAR就像输入一样简单:
Cassandra支持
现在为Cassandra提供自动配置。
OAuth2支持
您现在可以使用@EnableAuthorizationServer并@EnableResourceServer快速创建OAuth2授权和资源服务器。此外,@EnableOAuth2Client允许您的应用程序充当OAuth2客户端。
Spring Session
通过类路径上的Spring Session和Spring Data Redis,Web应用程序现在将自动配置为在Redis中存储用户会话。
jOOQ 支持
现在为jOOQ提供自动配置。您可以@Autowire将jOOQ DSLContext直接导入Spring Bean,以创建类型安全的数据库查询。通过spring.jooq.*应用程序属性支持其他自定义。
SendGrid
现在为SendGrid电子邮件传递服务提供自动配置。
Artemis自动配置
Apache Artemis成立于2015年,当时HornetQ被捐赠给了Apache Foundation。从Spring Boot 1.3开始,完全支持Apache Artemis,并且可以像HornetQ一样使用它。如果您要迁移到Artemis,则应将任何属性重命名为。spring.hornetq.spring.artemis.
验证“Starter POM”
您现在可以ResourceChainRegistration通过应用程序属性配置Spring的基本方面。
这允许您创建唯一的资源名称,以便您可以实现缓存清除。这些属性可用于根据资源的内容配置指纹识别; 如果要为指纹使用“固定版本”,可以使用和属性。
spring.resources.chain.strategy.content.spring.resources.chain.strategy.fixed.
JDBC
Spring Boot现在将自动从以下数据库的JDBC URL推断出驱动程序类名:
DB2
Firebird
Teradata
DataSource类型
现在可以通过spring.datasource.type配置键指定自动配置使用的连接池。
H2 Web控制台
已添加H2的Web控制台的自动配置。当您使用Spring Boot的开发人员工具时,只需在com.h2database:h2Web应用程序中添加依赖项即可开始使用。
嵌入式MongoDB
添加了嵌入式MongoDB的自动配置。依赖de.flapdoodle.embed:de.flapdoodle.embed.mongo是开始所需的全部内容。可以通过控制配置,例如要使用的Mongo版本application.properties。
ANSI颜色banner.txt文件
您现在可以在banner.txt文件中使用ANSI占位符来生成颜色输出。任何,,或属性将被扩大。例如:${Ansi.}${AnsiColor.}${AnsiBackground.}${AnsiStyle.}
默认配置文件application.properties
在-default加载时后缀现在被认为application.properties(和application.yml)文件时,没有特定的配置文件被激活。
当您使用配置文件指示部署环境时,这会很有用,例如:
应用参数
您现在可以将ApplicationRunner接口实现为替代CommandLineRunner。这可以以相同的方式工作,但提供参数作为ApplicationArguments接口而不是String[]。ApplicationArguments如果需要访问应用程序参数,也可以直接注入任何现有的bean。
该ApplicationArguments接口提供了访问“选项”和“非选项”参数的便捷方法。例如:
日志模式
该logging.pattern.console和logging.pattern.file性能,现在可以用来直接从您指定的日志记录模式application.properties。这可能很方便如果您只想自定义模式,因为您不再需要定义自己的log*.xml文件。
在stacktraces中jar细节
如果您使用的是logback或log4j2,我们现在会包含有关堆栈跟踪中每个类的加载位置的信息(可以通过此自定义logging.exception-conversion-word)。
Log4J 2输出
Log4J 2的默认输出已得到改进,现在类似于Logback生成的输出。
omcat访问日志
Tomcat访问日志具有更好的自定义:现在可以通过配置自定义目录和文件前缀/后缀。
Logback扩展
Spring Boot 1.3支持一些可用于您的logback配置文件的新标记。要使用标记,您需要先将任何logback.xml配置重命名为logback-spring.xml。重命名配置文件后,可以使用以下标记。
HTTP Sessions
持久的会议
更新Tomcat,Jetty和Undertow以在应用程序停止时序列化会话数据,并在应用程序重新启动时再次加载它。持续会议是选择加入; 通过设置persistentSession 在ConfigurableEmbeddedServletContainer或通过使用属性server.session.persistent=true(持久会话默认情况下,与Devtools启用)。
可以使用server.session.store-dir属性指定保存持久会话数据的位置。
高级HTTP会话配置
现在为会话配置提供了其他属性。您可以使用server.session.*属性配置“跟踪模式”和“cookie”详细信息。
X-Forwarded-For标头支持
X-Forwarded-For标头支持现在包含在Jetty和Undertow中。Tomcat支持也已刷新,因此如果应该遵守X-Forwarded-For标头server.use-forward-headers,true则可以设置单个属性。Spring Boot将检测Cloud Foundry或Heroku的部署并自动启用支持。
配置属性
如果您@ConfigurationProperties在bean 上使用,则不再需要添加@EnableConfigurationProperties到配置中,因为Spring Boot现在自动配置它。和以前一样,你可以让Spring @ConfigurationProperties使用value属性@EnableConfigurationProperties或使用常规@Bean定义为你的类创建一个bean 。
配置属性转换
如果您需要某些配置键的自定义类型转换而没有自定义ConversionService(带有bean ID conversionService),那么您现在需要限定Converter要使用的bean,@ConfigurationPropertiesBinding因为我们不再查找所有Converterbean。
消息
可以通过配置轻松禁用JMS和Rabbit端点。如果不存在,则创建的默认容器工厂也可以通过配置进行自定义。
国际化
现在可以通过配置键配置fallbackToSystemLocale自动配置MessageSource实例的标志spring.messages.fallback-to-system-locale。
自动配置
自动配置报告现在有一个名为“无条件类”的附加部分。它列出了没有任何类级别条件的任何自动配置类,即该类将始终是应用程序配置的一部分。它现在还列出了通过@SpringBootApplication(exclude=…)或手动排除的配置@EnableAutoConfiguration(exclude=…)。
现在可能还通过排除自动配置类spring.autoconfigure.excludes属性。类似地,@ImportAutoConfiguration希望有选择地导入某些自动配置类的测试可以使用新的注释。
MVC错误处理
该error.include-stacktrace属性现在可用于确定何时应在MVC错误响应中包含堆栈跟踪属性。选项是never,always或on-trace-param(never默认)。
执行器指标
该spring-boot-actuator指标的支持已经扩展到支持出口和聚集。此外,现在提供(并在可能时使用)Java 8特定GaugeService和CounterService实现,这提供了改进的性能。
额外的Health Indicators
HealthIndicators现在提供附加功能并自动配置为:
电子邮件
JMS
新的actuator endpoints
Spring Boot 1.3增加了以下额外的执行器端点:
CORS支持执行器端点
Actuator的端点现在支持CORS。默认情况下禁用支持,但可以通过配置启用endpoints.cors.allowed-origins。
正则表达式支持/env和/metrics
现在,您可以使用正则表达式过滤/env和/metrics执行端点。例如。http://localhost:8080/metrics/.root.
用于MVC执行器端点的超媒体
现在,当你的类路径上有Spring HATEOAS时,执行器HTTP端点会通过超媒体链接得到增强(例如,通过spring-boot-starter-hateoas)。还提供了新的“发现页面”,其具有到所有致动器端点的链接。如果HAL浏览器的webjar位于类路径上,则还为HAL浏览器提供支持。
执行器docs端点
spring-boot-actuator-docsSpring Boot 1.3提供了一个新模块,可以将执行器文档嵌入到您的应用程序中。一旦模块在类路径上,您就可以点击/docs以获取有关执行器端点的信息,包括每个端点返回的数据样本。
禁用health indicators
现在可以通过management.health.defaults.enabled属性轻松禁用所有默认运行状况指示器。
TraceWebFilter选项
执行器TraceWebFilter(用于跟踪HTTP请求/响应详细信息)现在可以记录更多信息。使用该management.trace.include属性配置要包含的选项(请参阅TraceProperties.Include枚举)。
Maven支持
Maven启动/停止支持和管理功能
Maven插件现在包括start和stop目标。这些可以在不阻止Maven的情况下启动应用程序(允许其他目标在应用程序上运行)。这种技术通常用于从Maven启动集成测试。
这项工作的副产品是添加了一个新SpringApplicationAdminMXBean接口(启用时)允许通过JMX控制Spring Boot应用程序。
资料激活
在spring-boot-maven-plugin现在包括一个profiles可与使用性能spring-boot:run。您可以在命令行中配置pom.xml或使用配置文件-Drun.profiles。
Ant支持
Spring Boot现在包含一个AntLib模块,可帮助您从Ant创建可执行jar。请参阅参考文档中的“Spring Boot AntLib模块”部分。
配置属性元数据更新
该META-INF/spring-configuration-metadata.json文件格式已经被更新,以支持新的deprecation和hints属性。IDE开发人员可以使用提示来提供更好的内容辅助支持。弃用允许弃用和替换密钥(如果有)。可以通过添加@DeprecatedConfigurationProperty酒店的吸气剂来提供此类信息。
我们还改进了默认值的检测:如果通过具有单个参数的方法调用初始化属性,我们认为所述参数是默认值(Charset.forName(\"UTF-8\")即将检测UTF-8为默认值)。
spring-boot-configuration-metadata现在,任何希望在自己的工具和应用程序中使用配置元数据的工具开发人员都可以使用新模块; 它提供了一个API来读取元数据并从中构建存储库。
Spring Boot CLI
CLI现在将使用settings.xml在依赖项解析期间在Maven中配置的存储库。对于要使用的存储库,声明它的配置文件必须处于活动状态。
CLI现在还可以生成可执行的WAR文件。使用$ spring war <filename.war> <script.groovy>。
Spring Boot 1.3还包含以下杂项更新:
使用Java 8时,Jackson的Java 8模块将自动注册。
TransactionTemplate现在包含一个bean作为其中的一部分TransactionAutoConfiguration。
甲MailServer豆现在可以通过JNDI通过使用所获得spring.mail.jndi-name属性。
您现在可以通过server.display-name属性配置servlet名称(使用嵌入式servlet容器时)。
现在可以通过FlywayMigrationStrategybean 配置Flyway迁移策略。
添加了一个新SpringBootVersion类(类似于SpringVersion核心框架)。
您现在可以使用hamcrest匹配器OutputCapture来验证测试产生的输出。
您现在可以将Spring Boot配置为使用Elasticsearch非本地节点。
该ApplicationPidFileWriter如果现在抛出一个异常fail-on-write-error属性设置(见更新的javadoc)。
Maven插件现在包含一个useTestClasspath使用选项spring-boot:run。
现在为DB2和Informix提供了额外的数据库健康查询。
属性绑定失败现在包括更好的异常消息。
该@SpringBootApplication注释现在包括scanBasePackages和scanBasePackageClasses属性。
新的AllNestedConditions和NoneNestedConditions提供的(类似于现有的AnyNestedCondition)
现在,应用程序启动时,活动配置文件将打印到输出日志。
该spring.main.banner-mode属性可以被用于之间切换CONSOLE,LOG或OFF输出。
远程DevTools现在可以在代理服务器后面工作(参见spring.devtools.remote.proxy.*属性)
Jackson’s的参数名称模块(提供Java 8支持)现在将在类路径上自动配置。
Spring的WebSocket消息转换器现在将自动配置。
DelegatingFilterProxyRegistrationBean添加了一个新类,允许通过a DelegatingFilterProxy。使用嵌入式servlet容器注册过滤器。
Spring Boot 1.3.0中的弃用
这些Application.showBanner和ApplicationBuilder.showBanner方法已经被弃用了setBannerMode。
@ConditionalOnMissingClass现在希望使用value属性而不是使用属性来提供类名name。
Log4JLoggingSystem现在,在Apache的log4j 1.x的EOL声明之后,它已被弃用。
这些ConfigurableEmbeddedServletContainer setJspServletClassName和setRegisterJspServlet方法已被替换setJspServlet。
将EndpointMBean类(和子类)现在预计的ObjectMapper要提供给构造函数。
在DropwizardMetricWriter已经换成DropwizardMetricService。
SpringApplication.afterRefresh采用a 的受保护方法String[]已被弃用,而不是采用的版本ApplicationArguments。
VcapEnvironmentPostProcessor已被弃用赞成CloudFoundryVcapEnvironmentPostProcessor。
该LoggingSystem initialize方法已被弃用,以支持接受的版本LoggingInitializationContext。
在ServerPortInfoApplicationContextInitializer已被弃用,将其移动到一个新的软件包
org.springframework.boot.autoconfigure.orm.jpa.EntityManagerFactoryBuilder已被弃用以将其移至新包。org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder应该用来代替。不再自动配置旧类型的bean。如果您的应用程序使用此bean,则应更新它以使用该org.springframework.boot.orm.jpa.EntityManagerFactoryBuilderbean。
0 条评论
回复 删除
下一页