Я использую spring-boot-starter-web последнюю версию 2.2.6. Но мое приложение всегда возвращает ноль для переменной с аннотацией @value.
Мой build.gradle,
plugins {
id 'com.google.cloud.tools.jib' version '2.1.0'
id 'org.springframework.boot' version '2.2.6.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
id 'eclipse'
id 'idea'
id 'maven-publish'
}
jar {
archiveBaseName = 'my-project'
project.version = '1.0.0'
}
repositories {
jcenter()
mavenCentral()
mavenLocal()
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
dependencies {
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '+'
implementation('org.springframework.boot:spring-boot-starter-web:+') {
exclude module: 'spring-boot-starter-tomcat'
}
implementation("org.springframework.boot:spring-boot-starter-jetty:+")
implementation group: 'io.springfox', name: 'springfox-swagger2', version: '2.8.0'
implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.8.0'
implementation group: 'io.kubernetes', name: 'client-java', version: '+'
implementation group: 'com.google.cloud', name: 'google-cloud-dataproc', version: '+'
implementation(project(':my-project-1')) {
exclude group: 'org.yaml'
}
implementation project(':my-project2')
}
tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:unchecked'
options.deprecation = true
}
Мой Java код,
@Component
public class MyClass {
@Value("${dataproc.host}")
private static String dataprocEndpoint;
Мой application.yml
dataproc:
host: dataproc.googleapis.com:443
Мое приложение. java,
@SpringBootApplication
@EnableSwagger2
@Configuration
public class Application {
private static final Logger LOGGER = LoggerFactory.getLogger(Application.class);
private transient String PATTERNS_TO_HIDE = "^/(?!error|autoconfig|beans|profile|info|health|pause|env|refresh|resume|restart|actuator|dump|mappings|trace|metrics|heapdump|archaius|configprops|features|liquibase|loggers|auditevents).*$";
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public Docket api() {
ApiInfo apiInfo = new ApiInfoBuilder().license("Proprietary").title("My Application")
.description("My Application").build();
return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.any())
.paths(PathSelectors.regex(PATTERNS_TO_HIDE)).build().pathMapping("/").apiInfo(apiInfo)
.useDefaultResponseMessages(false)
.globalResponseMessage(RequestMethod.GET, newArrayList(new ResponseMessageBuilder().code(500)
.message("500 message").responseModel(new ModelRef("Error")).build()));
}
}
Всегда получая значение NULL при запуске сервера, dataprocEndpoint: null
В какой конфигурации я здесь отсутствует?
Пожалуйста, предоставьте свои данные здесь.