Spring-boot: migrating to SpringBoot 2.0 ServerPropertiesAutoConfiguration cannot be opened because it does not exist

Created on 27 Apr 2018  路  7Comments  路  Source: spring-projects/spring-boot

Hello, I am migrating to SpringBoot 2.0, While performing the upgrade I am getting the following error. Can you please help me?

Application Version: 
Spring Boot Version: 2.0.1.RELEASE (v2.0.1.RELEASE)
2018-04-27 15:10:34.087  INFO 17160 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://192.168.0.226:9001/
2018-04-27 15:10:34.547  INFO 17160 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=lhw-qingyun-xs-user-service, profiles=[test], label=master, version=6135797957be9acc22e602e0e04d78342485a37c, state=null
2018-04-27 15:10:34.547  INFO 17160 --- [           main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource {name='configService', propertySources=[MapPropertySource {name='configClient'}, MapPropertySource {name='http://192.168.0.200/pinshang/document.git/configure-repo/test/lhw-qingyun-xs-user-service-test.yml'}]}
2018-04-27 15:10:34.637  INFO 17160 --- [           main] c.p.qingyun.ApplicationXSUserService     : The following profiles are active: test
2018-04-27 15:10:34.813  INFO 17160 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@7dd00705: startup date [Fri Apr 27 15:10:34 CST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@4de41af9
2018-04-27 15:10:35.983  WARN 17160 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.pinshang.qingyun.ApplicationXSUserService]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class] cannot be opened because it does not exist
2018-04-27 15:10:35.987  WARN 17160 --- [           main] o.s.b.c.p.m.PropertiesMigrationListener  : 
The use of configuration keys that have been renamed was found in the environment:

Property source 'bootstrapProperties':
    Key: security.user.name
        Replacement: spring.security.user.name
    Key: security.user.password
        Replacement: spring.security.user.password


Each configuration key has been temporarily mapped to its replacement for your convenience. To silence this warning, please update your configuration to use the new keys.

2018-04-27 15:10:35.988 ERROR 17160 --- [           main] o.s.b.c.p.m.PropertiesMigrationListener  : 
The use of configuration keys that are no longer supported was found in the environment:

Property source 'applicationConfig: [classpath:/application.yml]':
    Key: security.ignored
        Line: 2
        Reason: The security auto-configuration is no longer customizable.

Property source 'bootstrapProperties':
    Key: management.security.enabled
        Reason: A global security auto-configuration is now provided.
    Key: management.security.roles
        Reason: The security auto-configuration is no longer customizable.


Please refer to the migration guide or reference guide for potential alternatives.

2018-04-27 15:10:35.993  INFO 17160 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-04-27 15:10:36.010 ERROR 17160 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.pinshang.qingyun.ApplicationXSUserService]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class] cannot be opened because it does not exist
    at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:645)
    at org.springframework.context.annotation.ConfigurationClassParser.lambda$processDeferredImportSelectors$2(ConfigurationClassParser.java:564)
    at java.util.ArrayList.forEach(ArrayList.java:1249)
    at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:560)
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:188)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:316)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243)
    at com.pinshang.qingyun.ApplicationXSUserService.main(ApplicationXSUserService.java:29)
Caused by: java.io.FileNotFoundException: class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class] cannot be opened because it does not exist
    at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:180)
    at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:51)
    at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103)
    at org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory.createMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.java:88)
    at org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory.getMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.java:75)
    at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:81)
    at org.springframework.context.annotation.ConfigurationClassParser.asSourceClass(ConfigurationClassParser.java:731)
    at org.springframework.context.annotation.ConfigurationClassParser$SourceClass.getRelated(ConfigurationClassParser.java:1007)
    at org.springframework.context.annotation.ConfigurationClassParser$SourceClass.getAnnotationAttributes(ConfigurationClassParser.java:988)
    at org.springframework.context.annotation.ConfigurationClassParser.collectImports(ConfigurationClassParser.java:536)
    at org.springframework.context.annotation.ConfigurationClassParser.getImports(ConfigurationClassParser.java:509)
    at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:300)
    at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245)
    at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:635)
    ... 17 common frames omitted

ServerPropertiesAutoConfiguration was there in SpringBoot 1.5.x but is missing in 2.0. It might have changed but I am not finding any information on how we replace this class. anyone can help me, please!

stackoverflow

Most helpful comment

For me the reason was usage of [email protected]. Changing it to [email protected] fixed it.

All 7 comments

Nothing in Spring Boot refers to this class but com.pinshang.qingyun.ApplicationXSUserService does. It's unclear why this code is actually trying to import that auto-configuration. Why do you need this in the first place?

@snicoll com.pinshang.qingyun.ApplicationXSUserService is my main class, please ignore the class name, is's my bad.
the class content like this

package com.pinshang.qingyun;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.kafka.annotation.EnableKafka;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Controller
@SpringBootApplication
@EnableDiscoveryClient
@MapperScan(basePackages = "com.pinshang.qingyun.xsuser.mapper")
@ComponentScan(basePackages = { "com.pinshang.qingyun" })
@EnableKafka
public class ApplicationXSUserService implements WebMvcConfigurer {
    public static void main(String[] args) {
        SpringApplication.run(ApplicationXSUserService.class, args);
    }

    @GetMapping(value = { "", "/" })
    public String index() {
        return "redirect:/chk.html";
    }
}

You probably have a version of Spring Cloud that is incompatible with Spring Boot 2. For the sake of keeping the tracker clean, let's move this conversation to gitter.

@snicoll sorry, i'am in china, gitter is so slow.
my spring-boot version is 2.0.1.RELEASE, spring-cloud version is Finchley.RC1, but i was use spring-kafka, the version is 1.1.0.RELEASE, is any help?

Also experiencing the same thing with migrating from 1.5.10 to 2.0.6. Cloud version is Finchley.SR1.

app class annotations look like this:

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@ComponentScan({"com", "com.feign.client"})
@EnableDiscoveryClient
@EnableFeignClients

@rlperez import org.springframework.cloud.netflix.feign.EnableFeignClients doesn't exist in Finchley.SR1, you probably have an old version mixed up somehow. It moved to org.springframework.cloud.openfeign.EnableFeignClients.

For me the reason was usage of [email protected]. Changing it to [email protected] fixed it.

Was this page helpful?
0 / 5 - 0 ratings