eureka discovery client - selective disable










14















Is there a way to disable spring-boot eureka client registration based on the spring profile?



Currently I use the following annotations:



@Configuration
@EnableAutoConfiguration
@EnableDiscoveryClient
@EnableConfigServer

public class ConfigApplication
public static void main(String args)
SpringApplication.run(ConfigApplication.class, args);




What I need is either a conditional such as (excuse the pseudo code)



@if (Profile!="development")
@EnableDiscoveryClient
@endif


Or some way in the application properties file. I have tried setting application.yml file as:



spring:
profiles: development
cloud:
discovery:
enabled: false


But this did not work.










share|improve this question
























  • Possible duplicate of Including bean definition when a profile is NOT active

    – g00glen00b
    Feb 2 '16 at 7:03











  • To use class in all cases excluding one profile, you can write @Profile("!development")

    – dmitryvim
    Oct 14 '16 at 8:10















14















Is there a way to disable spring-boot eureka client registration based on the spring profile?



Currently I use the following annotations:



@Configuration
@EnableAutoConfiguration
@EnableDiscoveryClient
@EnableConfigServer

public class ConfigApplication
public static void main(String args)
SpringApplication.run(ConfigApplication.class, args);




What I need is either a conditional such as (excuse the pseudo code)



@if (Profile!="development")
@EnableDiscoveryClient
@endif


Or some way in the application properties file. I have tried setting application.yml file as:



spring:
profiles: development
cloud:
discovery:
enabled: false


But this did not work.










share|improve this question
























  • Possible duplicate of Including bean definition when a profile is NOT active

    – g00glen00b
    Feb 2 '16 at 7:03











  • To use class in all cases excluding one profile, you can write @Profile("!development")

    – dmitryvim
    Oct 14 '16 at 8:10













14












14








14


3






Is there a way to disable spring-boot eureka client registration based on the spring profile?



Currently I use the following annotations:



@Configuration
@EnableAutoConfiguration
@EnableDiscoveryClient
@EnableConfigServer

public class ConfigApplication
public static void main(String args)
SpringApplication.run(ConfigApplication.class, args);




What I need is either a conditional such as (excuse the pseudo code)



@if (Profile!="development")
@EnableDiscoveryClient
@endif


Or some way in the application properties file. I have tried setting application.yml file as:



spring:
profiles: development
cloud:
discovery:
enabled: false


But this did not work.










share|improve this question
















Is there a way to disable spring-boot eureka client registration based on the spring profile?



Currently I use the following annotations:



@Configuration
@EnableAutoConfiguration
@EnableDiscoveryClient
@EnableConfigServer

public class ConfigApplication
public static void main(String args)
SpringApplication.run(ConfigApplication.class, args);




What I need is either a conditional such as (excuse the pseudo code)



@if (Profile!="development")
@EnableDiscoveryClient
@endif


Or some way in the application properties file. I have tried setting application.yml file as:



spring:
profiles: development
cloud:
discovery:
enabled: false


But this did not work.







spring spring-boot netflix-eureka






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 10 '17 at 0:02









Marek J

72461325




72461325










asked Feb 1 '16 at 23:01









zinc wombatzinc wombat

78116




78116












  • Possible duplicate of Including bean definition when a profile is NOT active

    – g00glen00b
    Feb 2 '16 at 7:03











  • To use class in all cases excluding one profile, you can write @Profile("!development")

    – dmitryvim
    Oct 14 '16 at 8:10

















  • Possible duplicate of Including bean definition when a profile is NOT active

    – g00glen00b
    Feb 2 '16 at 7:03











  • To use class in all cases excluding one profile, you can write @Profile("!development")

    – dmitryvim
    Oct 14 '16 at 8:10
















Possible duplicate of Including bean definition when a profile is NOT active

– g00glen00b
Feb 2 '16 at 7:03





Possible duplicate of Including bean definition when a profile is NOT active

– g00glen00b
Feb 2 '16 at 7:03













To use class in all cases excluding one profile, you can write @Profile("!development")

– dmitryvim
Oct 14 '16 at 8:10





To use class in all cases excluding one profile, you can write @Profile("!development")

– dmitryvim
Oct 14 '16 at 8:10












6 Answers
6






active

oldest

votes


















22














Do it like this: create some @Configuration annotated class (class body can be omitted) ex.:



@Profile("!development")
@Configuration
@EnableDiscoveryClient
public class EurekaClientConfiguration



It means that this configuration file (and @EnableDiscoveryClient within) will be loaded in every profile except "developement".



Hope that helps,






share|improve this answer

























  • Thanks that was what I was looking for

    – zinc wombat
    Feb 7 '16 at 0:50











  • Upvoting this because it's an awesome answer.

    – ogradyjd
    Nov 2 '16 at 17:21











  • People who use SO tend to copy code right away. Please fix "developement".wasted my whole hour.

    – Sachin Verma
    Apr 11 '18 at 13:32











  • Fixed, sorry for that. I know how big pain in the ass is looking for something like that.

    – patrykos91
    Apr 11 '18 at 22:01


















48














You can disable eureka client in application.yml using this:



eureka:
client:
enabled: false


It's also for one profile






share|improve this answer




















  • 4





    Please add explanations to your answer.

    – Nikolay Mihaylov
    Jun 16 '16 at 8:11











  • in application.yml or application.properties you can set spring variables in different profiles, as it was written in third question code sample. I just suggested to disable eureka this way

    – dmitryvim
    Oct 14 '16 at 8:09


















5














Same issue here. You can simply put in your application property file the following configuration:



 spring:
profiles: development

eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false





share|improve this answer
































    5














    There is a standard boolean spring-cloud property



    spring.cloud.discovery.enabled



    This might be better than "eureka" specific since you might be using a different provider.






    share|improve this answer























    • In my case this doesn't work but eureka.client.enabled: false does.

      – Lu55
      Oct 8 '18 at 20:49


















    2














    With the latest version of Spring Cloud Finchley.SR2 if you are using the annotation @EnableDiscoveryClient you have to set all of the following properties in application.properties to disable the service registration:



    spring.cloud.service-registry.auto-registration.enabled=false
    eureka.client.enabled=false
    eureka.client.serviceUrl.registerWithEureka=false





    share|improve this answer






























      0














      With the latest version of Spring boot, Please add this in the bootstrap.yml file



      Spring cloud version : Edgeware: SR3 and above



      spring:
      application:
      name: test
      cloud:
      service-registry:
      auto-registration:
      enabled: false


      This will disable eureka. To enable it, we just need to make enabled as true






      share|improve this answer






















        Your Answer






        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "1"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f35142105%2feureka-discovery-client-selective-disable%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        6 Answers
        6






        active

        oldest

        votes








        6 Answers
        6






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        22














        Do it like this: create some @Configuration annotated class (class body can be omitted) ex.:



        @Profile("!development")
        @Configuration
        @EnableDiscoveryClient
        public class EurekaClientConfiguration



        It means that this configuration file (and @EnableDiscoveryClient within) will be loaded in every profile except "developement".



        Hope that helps,






        share|improve this answer

























        • Thanks that was what I was looking for

          – zinc wombat
          Feb 7 '16 at 0:50











        • Upvoting this because it's an awesome answer.

          – ogradyjd
          Nov 2 '16 at 17:21











        • People who use SO tend to copy code right away. Please fix "developement".wasted my whole hour.

          – Sachin Verma
          Apr 11 '18 at 13:32











        • Fixed, sorry for that. I know how big pain in the ass is looking for something like that.

          – patrykos91
          Apr 11 '18 at 22:01















        22














        Do it like this: create some @Configuration annotated class (class body can be omitted) ex.:



        @Profile("!development")
        @Configuration
        @EnableDiscoveryClient
        public class EurekaClientConfiguration



        It means that this configuration file (and @EnableDiscoveryClient within) will be loaded in every profile except "developement".



        Hope that helps,






        share|improve this answer

























        • Thanks that was what I was looking for

          – zinc wombat
          Feb 7 '16 at 0:50











        • Upvoting this because it's an awesome answer.

          – ogradyjd
          Nov 2 '16 at 17:21











        • People who use SO tend to copy code right away. Please fix "developement".wasted my whole hour.

          – Sachin Verma
          Apr 11 '18 at 13:32











        • Fixed, sorry for that. I know how big pain in the ass is looking for something like that.

          – patrykos91
          Apr 11 '18 at 22:01













        22












        22








        22







        Do it like this: create some @Configuration annotated class (class body can be omitted) ex.:



        @Profile("!development")
        @Configuration
        @EnableDiscoveryClient
        public class EurekaClientConfiguration



        It means that this configuration file (and @EnableDiscoveryClient within) will be loaded in every profile except "developement".



        Hope that helps,






        share|improve this answer















        Do it like this: create some @Configuration annotated class (class body can be omitted) ex.:



        @Profile("!development")
        @Configuration
        @EnableDiscoveryClient
        public class EurekaClientConfiguration



        It means that this configuration file (and @EnableDiscoveryClient within) will be loaded in every profile except "developement".



        Hope that helps,







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Apr 11 '18 at 22:00

























        answered Feb 2 '16 at 17:01









        patrykos91patrykos91

        1,4991222




        1,4991222












        • Thanks that was what I was looking for

          – zinc wombat
          Feb 7 '16 at 0:50











        • Upvoting this because it's an awesome answer.

          – ogradyjd
          Nov 2 '16 at 17:21











        • People who use SO tend to copy code right away. Please fix "developement".wasted my whole hour.

          – Sachin Verma
          Apr 11 '18 at 13:32











        • Fixed, sorry for that. I know how big pain in the ass is looking for something like that.

          – patrykos91
          Apr 11 '18 at 22:01

















        • Thanks that was what I was looking for

          – zinc wombat
          Feb 7 '16 at 0:50











        • Upvoting this because it's an awesome answer.

          – ogradyjd
          Nov 2 '16 at 17:21











        • People who use SO tend to copy code right away. Please fix "developement".wasted my whole hour.

          – Sachin Verma
          Apr 11 '18 at 13:32











        • Fixed, sorry for that. I know how big pain in the ass is looking for something like that.

          – patrykos91
          Apr 11 '18 at 22:01
















        Thanks that was what I was looking for

        – zinc wombat
        Feb 7 '16 at 0:50





        Thanks that was what I was looking for

        – zinc wombat
        Feb 7 '16 at 0:50













        Upvoting this because it's an awesome answer.

        – ogradyjd
        Nov 2 '16 at 17:21





        Upvoting this because it's an awesome answer.

        – ogradyjd
        Nov 2 '16 at 17:21













        People who use SO tend to copy code right away. Please fix "developement".wasted my whole hour.

        – Sachin Verma
        Apr 11 '18 at 13:32





        People who use SO tend to copy code right away. Please fix "developement".wasted my whole hour.

        – Sachin Verma
        Apr 11 '18 at 13:32













        Fixed, sorry for that. I know how big pain in the ass is looking for something like that.

        – patrykos91
        Apr 11 '18 at 22:01





        Fixed, sorry for that. I know how big pain in the ass is looking for something like that.

        – patrykos91
        Apr 11 '18 at 22:01













        48














        You can disable eureka client in application.yml using this:



        eureka:
        client:
        enabled: false


        It's also for one profile






        share|improve this answer




















        • 4





          Please add explanations to your answer.

          – Nikolay Mihaylov
          Jun 16 '16 at 8:11











        • in application.yml or application.properties you can set spring variables in different profiles, as it was written in third question code sample. I just suggested to disable eureka this way

          – dmitryvim
          Oct 14 '16 at 8:09















        48














        You can disable eureka client in application.yml using this:



        eureka:
        client:
        enabled: false


        It's also for one profile






        share|improve this answer




















        • 4





          Please add explanations to your answer.

          – Nikolay Mihaylov
          Jun 16 '16 at 8:11











        • in application.yml or application.properties you can set spring variables in different profiles, as it was written in third question code sample. I just suggested to disable eureka this way

          – dmitryvim
          Oct 14 '16 at 8:09













        48












        48








        48







        You can disable eureka client in application.yml using this:



        eureka:
        client:
        enabled: false


        It's also for one profile






        share|improve this answer















        You can disable eureka client in application.yml using this:



        eureka:
        client:
        enabled: false


        It's also for one profile







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jun 16 '16 at 13:02

























        answered Jun 16 '16 at 7:44









        dmitryvimdmitryvim

        7422719




        7422719







        • 4





          Please add explanations to your answer.

          – Nikolay Mihaylov
          Jun 16 '16 at 8:11











        • in application.yml or application.properties you can set spring variables in different profiles, as it was written in third question code sample. I just suggested to disable eureka this way

          – dmitryvim
          Oct 14 '16 at 8:09












        • 4





          Please add explanations to your answer.

          – Nikolay Mihaylov
          Jun 16 '16 at 8:11











        • in application.yml or application.properties you can set spring variables in different profiles, as it was written in third question code sample. I just suggested to disable eureka this way

          – dmitryvim
          Oct 14 '16 at 8:09







        4




        4





        Please add explanations to your answer.

        – Nikolay Mihaylov
        Jun 16 '16 at 8:11





        Please add explanations to your answer.

        – Nikolay Mihaylov
        Jun 16 '16 at 8:11













        in application.yml or application.properties you can set spring variables in different profiles, as it was written in third question code sample. I just suggested to disable eureka this way

        – dmitryvim
        Oct 14 '16 at 8:09





        in application.yml or application.properties you can set spring variables in different profiles, as it was written in third question code sample. I just suggested to disable eureka this way

        – dmitryvim
        Oct 14 '16 at 8:09











        5














        Same issue here. You can simply put in your application property file the following configuration:



         spring:
        profiles: development

        eureka:
        instance:
        hostname: localhost
        client:
        registerWithEureka: false
        fetchRegistry: false





        share|improve this answer





























          5














          Same issue here. You can simply put in your application property file the following configuration:



           spring:
          profiles: development

          eureka:
          instance:
          hostname: localhost
          client:
          registerWithEureka: false
          fetchRegistry: false





          share|improve this answer



























            5












            5








            5







            Same issue here. You can simply put in your application property file the following configuration:



             spring:
            profiles: development

            eureka:
            instance:
            hostname: localhost
            client:
            registerWithEureka: false
            fetchRegistry: false





            share|improve this answer















            Same issue here. You can simply put in your application property file the following configuration:



             spring:
            profiles: development

            eureka:
            instance:
            hostname: localhost
            client:
            registerWithEureka: false
            fetchRegistry: false






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited May 14 '16 at 8:03

























            answered May 13 '16 at 23:51









            Timi RuprechtTimi Ruprecht

            5113




            5113





















                5














                There is a standard boolean spring-cloud property



                spring.cloud.discovery.enabled



                This might be better than "eureka" specific since you might be using a different provider.






                share|improve this answer























                • In my case this doesn't work but eureka.client.enabled: false does.

                  – Lu55
                  Oct 8 '18 at 20:49















                5














                There is a standard boolean spring-cloud property



                spring.cloud.discovery.enabled



                This might be better than "eureka" specific since you might be using a different provider.






                share|improve this answer























                • In my case this doesn't work but eureka.client.enabled: false does.

                  – Lu55
                  Oct 8 '18 at 20:49













                5












                5








                5







                There is a standard boolean spring-cloud property



                spring.cloud.discovery.enabled



                This might be better than "eureka" specific since you might be using a different provider.






                share|improve this answer













                There is a standard boolean spring-cloud property



                spring.cloud.discovery.enabled



                This might be better than "eureka" specific since you might be using a different provider.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 4 '16 at 15:23









                RafaelRafael

                1,30611640




                1,30611640












                • In my case this doesn't work but eureka.client.enabled: false does.

                  – Lu55
                  Oct 8 '18 at 20:49

















                • In my case this doesn't work but eureka.client.enabled: false does.

                  – Lu55
                  Oct 8 '18 at 20:49
















                In my case this doesn't work but eureka.client.enabled: false does.

                – Lu55
                Oct 8 '18 at 20:49





                In my case this doesn't work but eureka.client.enabled: false does.

                – Lu55
                Oct 8 '18 at 20:49











                2














                With the latest version of Spring Cloud Finchley.SR2 if you are using the annotation @EnableDiscoveryClient you have to set all of the following properties in application.properties to disable the service registration:



                spring.cloud.service-registry.auto-registration.enabled=false
                eureka.client.enabled=false
                eureka.client.serviceUrl.registerWithEureka=false





                share|improve this answer



























                  2














                  With the latest version of Spring Cloud Finchley.SR2 if you are using the annotation @EnableDiscoveryClient you have to set all of the following properties in application.properties to disable the service registration:



                  spring.cloud.service-registry.auto-registration.enabled=false
                  eureka.client.enabled=false
                  eureka.client.serviceUrl.registerWithEureka=false





                  share|improve this answer

























                    2












                    2








                    2







                    With the latest version of Spring Cloud Finchley.SR2 if you are using the annotation @EnableDiscoveryClient you have to set all of the following properties in application.properties to disable the service registration:



                    spring.cloud.service-registry.auto-registration.enabled=false
                    eureka.client.enabled=false
                    eureka.client.serviceUrl.registerWithEureka=false





                    share|improve this answer













                    With the latest version of Spring Cloud Finchley.SR2 if you are using the annotation @EnableDiscoveryClient you have to set all of the following properties in application.properties to disable the service registration:



                    spring.cloud.service-registry.auto-registration.enabled=false
                    eureka.client.enabled=false
                    eureka.client.serviceUrl.registerWithEureka=false






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Dec 4 '18 at 10:24









                    ostmondostmond

                    5118




                    5118





















                        0














                        With the latest version of Spring boot, Please add this in the bootstrap.yml file



                        Spring cloud version : Edgeware: SR3 and above



                        spring:
                        application:
                        name: test
                        cloud:
                        service-registry:
                        auto-registration:
                        enabled: false


                        This will disable eureka. To enable it, we just need to make enabled as true






                        share|improve this answer



























                          0














                          With the latest version of Spring boot, Please add this in the bootstrap.yml file



                          Spring cloud version : Edgeware: SR3 and above



                          spring:
                          application:
                          name: test
                          cloud:
                          service-registry:
                          auto-registration:
                          enabled: false


                          This will disable eureka. To enable it, we just need to make enabled as true






                          share|improve this answer

























                            0












                            0








                            0







                            With the latest version of Spring boot, Please add this in the bootstrap.yml file



                            Spring cloud version : Edgeware: SR3 and above



                            spring:
                            application:
                            name: test
                            cloud:
                            service-registry:
                            auto-registration:
                            enabled: false


                            This will disable eureka. To enable it, we just need to make enabled as true






                            share|improve this answer













                            With the latest version of Spring boot, Please add this in the bootstrap.yml file



                            Spring cloud version : Edgeware: SR3 and above



                            spring:
                            application:
                            name: test
                            cloud:
                            service-registry:
                            auto-registration:
                            enabled: false


                            This will disable eureka. To enable it, we just need to make enabled as true







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 14 '18 at 13:14









                            denzaldenzal

                            574616




                            574616



























                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f35142105%2feureka-discovery-client-selective-disable%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                27

                                Top Tejano songwriter Luis Silva dead of heart attack at 64

                                Category:Rhetoric