public class Customer implements Callable<Person> {
@Autowired
private Environment env;
//dao logic
}
还有我的主要方法,例如:
@Configuration @ComponentScan({"org.test"}) @PropertySource("classpath:app.properties") public class Application { }
但是当我尝试自动装配Customer类中的Environment时,该实例返回null。我认为这是因为我的Customer类正在实现Callable iterface,但不确定为什么env为null。任何想法都值得赞赏。
@Component
public class Customer implements Callable<List<Person>> {
@Autowired
private Environment env;
//dao logic
}