Repository containing default microservice infrastructure set up using Spring configuration
Groovy Java Other
Switch branches/tags
stub-runner-spring-0.2.3 stub-runner-spring-0.2.2 stub-runner-spring-0.2.1 stub-runner-spring-0.2.0 stub-runner-spring-0.1.0 stub-runner-spring-0.0.1 stub-runner-0.3.3 stub-runner-0.3.2 stub-runner-0.3.1 stub-runner-0.3.0 stub-runner-0.2.2 stub-runner-0.2.1 stub-runner-0.2.0 stub-runner-0.1.0 stub-runner-0.0.1 release/2.0.50 release/2.0.49 release/2.0.48 release/2.0.47 release/2.0.46 release/2.0.45 release/2.0.44 release/2.0.43 release/2.0.42 release/2.0.41 release/2.0.40 release/2.0.39 release/2.0.38 release/2.0.37 release/2.0.36 release/2.0.35 release/2.0.34 release/2.0.33 release/2.0.32 release/2.0.31 release/2.0.30 release/2.0.29 release/2.0.28 release/2.0.27 release/2.0.26 release/2.0.25 release/2.0.24 release/2.0.23 release/2.0.22 release/2.0.21 release/2.0.20 release/2.0.19 release/2.0.18 release/2.0.17 release/2.0.16 release/2.0.15 release/2.0.14 release/2.0.13 release/2.0.12 release/2.0.11 release/2.0.10 release/2.0.9 release/2.0.8 release/2.0.7 release/2.0.6 release/2.0.5 release/2.0.4 release/2.0.3 release/2.0.2 release/2.0.1 release/2.0.0 release/0.9.8 release/0.9.7 release/0.9.6 release/0.9.5 release/0.9.4 release/0.9.3 release/0.9.2 release/0.9.1 release/0.9.0 release/0.8.24 release/0.8.23 release/0.8.22 release/0.8.21 release/0.8.20 release/0.8.19 release/0.8.18 release/0.8.17 release/0.8.16 micro-deps-spring-config-0.5.3 micro-deps-spring-config-0.5.2 micro-deps-spring-config-0.5.1 micro-deps-spring-config-0.5.0 micro-deps-spring-config-0.4.8 micro-deps-spring-config-0.4.7 micro-deps-spring-config-0.4.6 micro-deps-spring-config-0.4.4 micro-deps-spring-config-0.4.3 micro-deps-spring-config-0.4.2 micro-deps-spring-config-0.4.1 micro-deps-spring-config-0.4.0 micro-deps-spring-config-0.3.0 micro-deps-spring-config-0.2.2 micro-deps-spring-config-0.2.1 micro-deps-spring-config-0.2.0
Nothing to show
Clone or download
Latest commit 7d77b9b Apr 16, 2018

Build Status Coverage Status Download Stack Overflow Gitter


Sets up the whole Spring infrastructure stack that will turn your microservice into a beauty.

Check out the wiki to have a deeper insight into the project.


Currently we have two lines of versions.

Version greater than 2.0.0

This version is in the "master" branch and it contains micro-infra-spring integrated with Spring Cloud. We want to tightly couple micro-infra-spring with Spring Cloud thus this branch will be developed. All the new features will be also developed for this branch.

This version is backwards compatible - you can use both the old (microservice.json) and the new (Spring Cloud Zookeeper approach). To enable the new approach you have to provide the springCloud profile.

Versions smaller than 2.0.0

All versions smaller than 2.0.0 are related to the micro-infra-spring version that does not contain Spring Cloud integration (other than the micro-infra-config module). The code containing that version is present in the "legacy" branch. This branch in general will not be maintained. If someone wants a feature to be present here he first needs to develop it in the "master" branch and then backport it to the "legacy" branch. The "legacy" branch in general will not be maintained if it won't be essential.


Check boot-microservice for an example of a working application

Check spring-cloud-zookeeper documentation on how to register your application with properties in Zookeeper

My application doesn't seem to use SpringCloud capabilities

Ensure that you have ALSO passed the springCloud profile. For example:

./gradlew bootRun,springCloud -DAPP_ENV=prod -DCONFIG_FOLDER=/properties -Dserver.port=9090

Wrong version of spring boot


You may find issues like NoClassDefFoundError or ArrayStoreException. That most likely means that you have different versions of Spring on your classpath.

Example of an exception:

Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/boot/context/config/ConfigFileEnvironmentPostProcessor
	at org.springframework.boot.SpringApplication.applyInitializers(
	at pl.uservices.dojrzewatr.Application.main(
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.config.ConfigFileEnvironmentPostProcessor
	at java.lang.ClassLoader.loadClass(
	at sun.misc.Launcher$AppClassLoader.loadClass(
	at java.lang.ClassLoader.loadClass(
	... 6 more


Enforce Spring and Spring Boot library versions

configurations {
    all {
        resolutionStrategy {
            eachDependency { DependencyResolveDetails details ->
                if ( == 'org.springframework.boot') { details.useVersion '1.3.0.RC1' }
                if ( == 'org.springframework') { details.useVersion '4.2.2.RELEASE' }

ClientHttpRequestFactory duplicated beans


With Ribbon coming in you have another ClientHttpRequestFactory. If you autowire one in your codebase you'll get the following exception:

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.http.client.ClientHttpRequestFactory pl.uservices.dojrzewatr.brewing.BrewConfiguration.clientHttpRequestFactory; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.http.client.ClientHttpRequestFactory] is defined: expected single matching bean but found 2: requestFactory,ribbonClientHttpRequestFactory
	at org.springrk.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject( ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject( ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues( ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
	... 38 common frames omitted
Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.http.client.ClientHttpRequestFactory] is defined: expected single matching bean but found 2: requestFactory,ribbonClientHttpRequestFactory
	at ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
	at ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject( ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
	... 40 common frames omitted


Pass the @Qualifier("requestFactory") to get one from micro-infra

@Autowired @Qualifier("requestFactory") ClientHttpRequestFactory clientHttpRequestFactory;

ServiceConfigurationResolver missing


If you're using springCloud profile you might get the following exception

Unsatisfied dependency expressed through ... of type [com.ofg.infrastructure.discovery.ServiceConfigurationResolver]: : 
No qualifying bean of type [com.ofg.infrastructure.discovery.ServiceConfigurationResolver] found for dependency: 
expected at least 1 bean which qualifies as autowire candidate for this dependency. 
Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: 
No qualifying bean of type [com.ofg.infrastructure.discovery.ServiceConfigurationResolver] found for dependency: 
expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}


You have legacy code that requires JSON representation whereas right now you have to use the ZookeeperDependencies class. Together with ZookeeperDiscoveryProperties to retrieve the realm.

I want to use the old functionality of micro-infra but it blows up with Spring Cloud stuff

Ensure that you have a bootstrap.yaml file on your classpath that deregisters everything related to Spring Cloud. For example: false false
ribbon.zookeeper.enabled: false

Trying to connect to Zipkin

You might have such an exception when trying to boot up the application:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spanCollector' defined in class path resource [org/springframework/cloud/sleuth/zipkin/ZipkinAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.github.kristofa.brave.zipkin.ZipkinSpanCollector]: Factory method 'spanCollector' threw exception; nested exception is java.lang.IllegalStateException: org.apache.thrift.transport.TTransportException: Connection refused

That means that your application is trying to connect to Zipkin server and fails to do so. This will happen when you start your app in prod profile.


There are two approaches:

  • set spring.zipkin.enabled to false in bootstrap.yaml
  • set APP_ENV to a value that contains test or stage or rbt


We want to connect to Zipkin only if one has the production profile turned on and he has deployed his application to the production environment. One can override this functionality by setting the to false. Check out com.ofg.infrastructure.tracing.TracingPropertiesEnabler for more infromation.

Your .yaml properties file is not taken into account

You might find out that your .yaml file doesn't override .properties files. This is caused by way spring-boot is processing directories when looking for properties. For now there is no solution for this issue.

Missing org.springframework.web.client.RestTemplate

If you getting

NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.web.client.RestTemplate]

That means that you don't have any RestTemplate instance in your context


Add to your bootstrap.properites/.yml file this line: false