Spring Aware
在实际项目中,不可避免的要用到 spring容器本身的功能资源,这时你得bean必须要意识到spring容器的存在,才能调用spring所提供的资源,
这就是所谓的spring aware 本来就是spring设计用来框架内部使用的,若使用了spring aware 你的bean将会和spring 框架耦合
文件位置:com/springaware/text.txt n内容随意写
package com.springaware;
import java.io.IOException;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Service;
@Service
public class AwareService implements BeanNameAware, ResourceLoaderAware {
private String beanName;
private ResourceLoader loader;