| |
方面滤 |
|
File: context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="bean">
<context:include-filter type="annotation" expression="bean.Magic"/>
<context:include-filter type="assignable" expression="bean.ComponentMarker"/>
<context:include-filter type="aspectj" expression="* void bean.*Service*(..)"/>
</context:component-scan>
</beans>
File: Main.java
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Main {
public static void main(String[] args) throws Exception {
ApplicationContext ac = new ClassPathXmlApplicationContext(
"context.xml");
String[] beanNames = ac.getBeanDefinitionNames();
for (String beanName : beanNames) {
System.out.println(beanName + ": " + ac.getBean(beanName));
}
}
}
|
|
Spring-AspectFilter.zip( 4,453 k) |
Related examples in the same category |
|