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.