donovanmuller / spring-cloud-deployer-openshift

A Spring Cloud Deployer SPI implementation for OpenShift 3
http://blog.switchbit.io/spring-cloud-deployer-openshift
Apache License 2.0
4 stars 10 forks source link

Duplicate KubernetesDeployerProperties #52

Closed kalvarez2 closed 6 years ago

kalvarez2 commented 6 years ago

Tried to use as a dependency in my project. Just added a REST controller to expose the AppDeployer API as REST entry points, when the application boots I get :

Field properties in org.springframework.cloud.deployer.spi.kubernetes.KubernetesAutoConfiguration required a single bean, but 2 were found:
    - spring.cloud.deployer.kubernetes-org.springframework.cloud.deployer.spi.kubernetes.KubernetesDeployerProperties: defined in null
    - spring.cloud.deployer.openshift-org.springframework.cloud.deployer.spi.openshift.OpenShiftDeployerProperties: defined in null

I am using version 1.3.0.BUILD-SNAPSHOT:


                <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-deployer-openshift</artifactId>
            <version>1.3.0.BUILD-SNAPSHOT</version>
        </dependency>

and my parent pom points to:

       <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.8.RELEASE</version>
        <relativePath />
    </parent>
donovanmuller commented 6 years ago

Hi @kalvarez2!

Thanks for the feedback. You have to exclude KubernetesAutoConfiguration in your application.

See the Spring Cloud Data Flow Server for an example:

@SpringBootApplication(exclude = KubernetesAutoConfiguration.class)
@EnableDataFlowServer
public class OpenShiftDataFlowServer {

    public static void main(String[] args) {
        SpringApplication.run(OpenShiftDataFlowServer.class, args);
    }
}
kalvarez2 commented 6 years ago

Thanks! that solves it. Interestingly, even after excluding it was showing up duplicate, because I had a @EnableAutoConfiguration like this:


@SpringBootApplication(exclude = KubernetesAutoConfiguration.class)
@EnableAutoConfiguration
public class MyApplication {
    public static void main(String[] args) {
        SpringApplication.run(MyApplication.class, args);
    }
}

thanks again!

donovanmuller commented 6 years ago

If you use @SpringBootApplication it already uses @EnableAutoConfiguration. Using it again causes conflicts. See https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-using-springbootapplication-annotation.html

kalvarez2 commented 6 years ago

I really have no idea why I had it there...