Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Bean with Factory Method from XML to Java Config

Tags:

java

spring

Which is the properly 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 the following solution right?

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

Is there a better implementation according to the Spring-philosophy?

Cheers, V.

like image 504
vdenotaris Avatar asked Apr 22 '14 08:04

vdenotaris


Video Answer


1 Answers

The way you are doing it seems right.

Check out this blog post.

like image 55
geoand Avatar answered Oct 19 '22 23:10

geoand