Spring Bean Using Factory Method from XML to Java Config

What is the correct way to translate this bean:

<bean id="velocityEngine" class="org.springframework.security.saml.util.VelocityFactory" factory-method="getEngine"/> 

from XML to Java-Config (note the factory method)?

Is this the following solution correct?

 @Bean public VelocityEngine veloctyEngine() { return VelocityFactory.getEngine(); } 

Is there a better implementation according to Spring-philosophy?

Greetings B.

+6
source share
1 answer

The way you do this seems right.

Bookmark this blog post.

+3
source

All Articles