1

我在我的 spring context.xml 中使用以下配置来注册 Java 旋律配置的模式。我想把它作为春豆移出来。谁能帮我这个?我无法正确设置它。

 <bean id="facadeMonitoringAdvisor" class="net.bull.javamelody.MonitoringSpringAdvisor">
        <property name="pointcut">
                <bean class="org.springframework.aop.support.JdkRegexpMethodPointcut">
                        <property name="patterns" value="com.abc.service.*.*(..)" />
                        <property name="excludedPatterns" value="com.abc.service.*.getEntityManager(),com.abc.service.xyz.integration.gateway.*,com.abc.service.xyz.webservice.*" />
                </bean>
        </property>
</bean>
4

2 回答 2

1

你应该创建一个@Configuration类。对于 xml 中的每个bean标签,创建一个用@Bean. 在这种情况下,它看起来像这样:

@Configuration
public class MonitoringContext
{
    @Bean(name="facadeMonitoringAdvisor")
    public MonitoringSpringAdvisor getMonitoringSpringAdvisor() {
         MonitoringSpringAdvisor msa = new MonitoringSpringAdvisor();
         msa.setPointcut(getJdkRegexpMethodPointcut());
         return msa;
    }

    @Bean
    public JdkRegexpMethodPointcut getJdkRegexpMethodPointcut() {
         JdkRegexpMethodPointcut jrm = new JdkRegexpMethodPointcut();
         jrm.setPatterns("com.abc.service.*.*(..)");
         jrm.setExcludedPatterns("com.abc.service.*.getEntityManager(),com.abc.service.xyz.integration.gateway.*,com.abc.service.xyz.webservice.*");
         return jrm;
    }
}
于 2014-03-13T18:35:15.127 回答
0

在此处查看 AOP 的 Spring 文档

于 2014-03-13T18:08:47.100 回答