3

What is the equivalent of

<bean id="myClass" class="com.xxx.MyClass" factory-method="aspectOf" />

when using a Spring 4 @Bean-annotated method?

Steve Chambers
  • 37,270
  • 24
  • 156
  • 208

2 Answers2

0

There is no annotation for the factory method, but you can use the @Configuration and @Bean annotations

@Configuration
public class MyClass {

    @Bean
    public MyClass myObject() {
        return MyStaticFactory.getObject();
    }

}

MyStaticFactory does not require any Spring annotations.

-1

Use @Configurable with <context:spring-configured>

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Sarab
  • 1