升级公司framework依赖的spring boot版本,从1.3.2.RELEASE升级到1.5.1.RELEASE
解决方案:
1.spring boot版本主要更新内容
- Spring Boot 1.4.0 Release Notes
1) TestRestTemplate:theTestRestTemplate
class no longer directly extendsRestTemplate
(although it continues to offer the same methods). This allowsTestRestTemplate
to be configured as a bean without it being accidentally injected. If you need access to the actual underlyingRestTemplate
use thegetRestTemplate()
method.
2) @Transactional:default to cglib proxies When Boot auto-configures the transaction management, proxyTargetClass
is now set to true
3) Test improvements:Spring Boot 1.4 includes a major overhaul of testing support. Test classes and utilities are now provided in dedicated spring-boot-test
and spring-boot-test-autoconfigure
jars (although most users will continue to pick them up via the spring-boot-starter- test
"Starter"). We’ve added AssertJ, JSONassert and JsonPath dependencies to the test starter
1) Spring Session store:Previously, if you had Spring Session and Redis with no particular configuration, Redis was automatically used to store sessions. You now need to specify the store type; existing users of Spring Session with Redis should add the following to their configuration:
spring.session.store-type=redis
2) Apache Kafka support:Spring Boot 1.5 include auto-configuration support for Apache Kafka via the spring-kafka
project. To use Kafka simply include the spring-kafka`depenency and configure the appropriate `spring.kafka.*
application properties
3) LDAP support:Spring Boot now offers auto-configuration for any compliant LDAP server as well as support for the embedded in-memory LDAP server from Unbounded.See the documentation for more details.
2. 升级过程中遇到的问题
spring boot中SpringBootServletInitializer类已经修改,需要对公司framework框架中ApplicationStarter进行重写,修改run方法
// @Override
// protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
// return application.sources(CoreConfig.class);
// }
public
static
void
run(Class<?> assemblyClass, String[] args) {
if
(instance ==
null
) {
synchronized
(ApplicationStarter.
class
) {
if
(instance ==
null
) {
logger.info(
"start run a new instance."
);
instance =
new
ApplicationStarter()
.configure(
new
SpringApplicationBuilder(CoreConfig.
class
, ApplicationStarter.
class
, assemblyClass))
.profiles(
"localResource"
,
"healthCheck"
).properties(defaultProperties())
.run(args);
checkAppicationName(instance);
}
else
{
logger.warn(
"instance is not null, can't run a new one."
);
}
}
}
else
{
logger.warn(
"instance is not null, can't run a new one."
);
}
}
FF4j\druid ServletRegistrationBean类改变
//升级前
import
org.springframework.boot.web.servlet.ServletRegistrationBean;
//升级后
import
org.springframework.boot.context.embedded.ServletRegistrationBean;
- 测试案例中的 TestRestTempalte已经从spring-boot release包中移除,需引入spring-boot-starter-test
- @Transactional默认开启cglib代理,导致FF4J无法使用,已把问题提交给FF4J作者
- @SpringApplicationConfiguration已经被废弃,可以用@ContextConfiguration替换
- 测试案例需要进行修改,并引入
spring-boot-starter-test
- 升级前jar包大小75447KB,升级后87010KB