我在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>
答案 0 :(得分: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;
}
}
答案 1 :(得分:0)
查看AOP here
的Spring文档