本文介绍了通过Spring将Google番石榴缓存构建器注入bean的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以通过 Spring xml为一个依赖bean构建并注入Google guava的 CacheBuilder 一个很好的片段?

Could some one provide a good snippet to construct and inject Google guava's CacheBuilder into a dependent bean via Spring xml?

为了概括,我需要在 Spring 中使用构建器模式构建对象的一些示例。

To generalize, I need some examples in Spring that illustrates construction of objects using builder pattern.

推荐答案

虽然可以,你会发现它几乎不可能用于Builder-Pattern风格的链式调用。

While it's possible to call arbitrary methods in Spring XML using the factory-method attribute, you'll find that it's close to impossible for Builder-Pattern style chained calls.

相反,使用或。我担心XML不会让你这么远。

Instead, use a FactoryBean or Java-based container configuration for such complex scenarios. XML will not get you that far, I'm afraid.

这篇关于通过Spring将Google番石榴缓存构建器注入bean的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-26 22:12
查看更多