您可以在构建Spring Boot应用程序时使用初始化程序:
@SpringBootApplicationpublic class SpringBootApp { public static void main(String... args) { new SpringApplicationBuilder(SpringBootApp.class) .initializers(new ApplicationContextInitializer<GenericApplicationContext>() { @Override public void initialize(GenericApplicationContext applicationContext) { applicationContext.setAllowBeanDefinitionOverriding(false); } }) .run(args); }}
或使用Java 8:
new SpringApplicationBuilder(SpringBootApp.class) .initializers((GenericApplicationContext c) -> c.setAllowBeanDefinitionOverriding(false) ) .run(args);
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)