简体   繁体   中英

CloudException: No suitable cloud connector found

My project has dependencies on spring-boot-starter-cloud-connectors and spring-cloud-localconfig-connector . Here is my code:

@Configuration
class MyConfig {

    @Bean
    public CloudFactory cloudFactory() {
        CloudFactory cf = new CloudFactory();
        cf.registerCloudConnector(new LocalConfigConnector());
        return cf;
    }

}

@Component
class MyComponent {

    @Autowired
    CloudFactory cf;

    @EventListener(value = ApplicationStartedEvent.class)
    public void postConstruct() {
        Cloud cloud = cf.getCloud();
    }

}

When I try to run the above code locally, I get an exception saying:

org.springframework.cloud.CloudException: No suitable cloud connector found

Although, the parent's version is irrelevant but I am using 2.1.8.RELEASE .

Can someone point out what's wrong with the above code?

You have to add the default datasource:

mysql://user:password@localhost:3306/databasename

You can set it using the run configuration or create a seperate properties file for it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM