我知道如何创建自定义注释,但不理解其内部工作原理。以Spring注释为例。
@PropertySource(value = { "classpath:database.properties" }).
如果我们查看@PropertySource注释的内部细节
@Target({ java.lang.annotation.ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Repeatable(PropertySources.class)
public @interface PropertySource {
public abstract String name();
public abstract String[] value();
public abstract boolean ignoreResourceNotFound();
}
我们这里没有提供加载属性文件的实现。那么它是如何从类路径加载属性文件的?背后是谁在工作?