Are there anyway to disable annotation in spring4?
You would want to work with Spring Boot Profiles. Split out the @EnableEurekaClient
to another @Configuration
class and also add an @Profile("eureka-client")
to the class. Then when starting up the application you can set a -Dspring.profiles.active=eureka-client
for the environments other than production.
Example:
@SpringBootApplication
@EnableCaching
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
}
@Configuration
@EnableEurekaClient
@Profile("eureka-client")
public class EurekaClientConfiguration {
}