Register ApplicationConversionService for context

Update `SpringApplication` to automatically register the shared
`ApplicationConversionService` instance with the `BeanFactory` and
`Environment`.

Closes gh-12148
This commit is contained in:
Phillip Webb
2018-09-11 14:21:56 -07:00
parent ab6bdc7ae2
commit 0c00508b3c
6 changed files with 74 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
package sample.simple.service;
import java.time.Duration;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@@ -25,8 +27,15 @@ public class HelloWorldService {
@Value("${name:World}")
private String name;
@Value("${duration:10s}")
private Duration duration;
public String getHelloMessage() {
return "Hello " + this.name;
return "Hello " + this.name + " for " + this.duration.getSeconds() + " seconds";
}
public Duration getDuration() {
return this.duration;
}
}