0
  1. I am using spring boot 2.1.9 version trying to migrate my project from spring boot1.x to 2.x.
  2. I am getting following exception while running the application. I have added following dependency to fix the issue
    <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)
Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
kumar
  • 1
  • 2
  • which cloud provider are you connecting to ? – Shailesh Chandra Nov 01 '19 at 03:24
  • you will get this exception if the application is not running on one of the supported cloud platforms (Cloud Foundry or Heroku), or with the appropriate localconfig configuration. are you running the app on one of these cloud platforms? – Scott Frederick Nov 01 '19 at 14:02

0 Answers0