0
  1. 我正在使用 spring boot 2.1.9 版本试图将我的项目从 spring boot1.x 迁移到 2.x。
  2. 运行应用程序时出现以下异常。我添加了以下依赖项来解决问题
    <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-cloud-connectors</artifactId>
            </dependency>



     @Configuration
    public class CloudConfiguration {

        private Logger logger = LoggerFactory.getLogger(CloudConfiguration.class);

        private static final String CLOUD_PROP_NOT_FOUND = "Warning: Cloud properties are not loaded! ";


        @Bean(name="cloudFactoryProperties")
        public Properties loadCloudProperties() {
            Properties props = null;//new Properties();
            try {
                props = factory().getCloud().getCloudProperties();//getting exception here
                logger.info("Cloud properties : {}", props);
            } catch (Exception e) {
                logger.error("Exception while try to load the cloud properties");
            }
            if (props == null) {
                //logger.warn(CLOUD_PROP_NOT_FOUND);
            }
            return props;
        }

        private CloudFactory factory(){
            return new CloudFactory();
        }

        @Bean
        public RestTemplate restTemplate() {
            return new RestTemplate();
        }
    }

        I am getting this exception.
        org.springframework.cloud.CloudException: No suitable cloud 
        connector found at org.springframework.cloud.CloudFactory.getCloud(CloudFactory.java:55)
4

0 回答 0