Spring的Environment必须通过实现EnvironmentAware接口才能注入吗

下面这个类能成功注入Environment吗?为什么我的是null

 @Configuration
public class PropertyConfigurer {

    @Autowired
    private  Environment env;

    public  String getProperty(String name) {
        return env.getProperty(name);
    }
}

修改成如下就可以了,我就是想知道是不是必须通过实现EnvironmentAware才能注入Environment

@Configuration
public class PropertyConfigurer implements EnvironmentAware{

//    @Autowired
    private static Environment env;

    public static String getProperty(String name) {
        return env.getProperty(name);
    }

    @Override
    public void setEnvironment(Environment environment) {
        env=environment;
    }
}

你不会导错包了吧,import org.springframework.core.env.Environment;

肯定不是啊,这是Environment的两种使用方式