Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
499 views
in Technique[技术] by (71.8m points)

spring boot - Is there a way to @Import configuration and override the behavior of one of the bean?

I'm trying to create @Configuration class which will be @Import in different run time (in my project). The configuration will create instance and I want for every run time to let him to do something else (like abstract behavior).

For example:

@Configuration
public class ConfigurationClass {
   @Bean
   public SomeInstace getInstance {
       doSomething();
       return new SomeInstance()
   }

   public abstract void doSomething();
}

//run time configuration class
@Import({ConfigurationClass.class})
@Configuration
public class RunTimeConfiguration{

   @Override
   public void doSomething(){
      System.out.println("Do somthething else");
   }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...