或者,以另一种方式-有什么更好的方法-使用自动装配:private BeanFactorybeanFactory;@Configurationpublic class MyConfigurationClass implements BeanFactoryAware {
public void setBeanFactory(final B
我有一个Spring,我在其中声明Jetty server ApplicationContext并启动它。在Jetty中,我有一个DispatcherServlet和几个控制器。如何使DispatcherServlet及其控制器使用来自声明Jetty的同一个ApplicationContext的bean?
作为大多数Spring的新用户,我对@Autowired :D有一个问题。假设我们有这个Spring层次结构:public class DemoApplication {
SpringApplication.run(DemoApplication.class, args);}@Service
public class
beanFactory, final ExecutorService delegate),所以我需要将代码更改为如下所示:@RequiredArgsConstructor(onConstructorbeanFactory; @Autowired
private final BeanFactory正如我在这里所读到的:,我们可以通过以下方式创建这个BeanFa