如何在Spring Boot中的不同类中访问注入的变量?

huangapple 未分类评论46阅读模式
英文:

How can I access an injected variable in a different class in Spring Boot?

问题

private final ExampleRepository exampleRepository;

@Autowired
public MainController(ExampleRepository exampleRepository) {
    super();
    this.exampleRepository = exampleRepository;
}

如何在不同类的静态方法中访问通过依赖注入注入的 exampleRepository 变量?

英文:
private final ExampleRepository exampleRepository;

@Autowired
public MainController(ExampleRepository exampleRepository) {
    super();
    this.exampleRepository = exampleRepository;
}

How can I access this injected exampleRepository variable by a static method in a different class?

huangapple
  • 本文由 发表于 2020年5月3日 18:46:43
  • 转载请务必保留本文链接:https://java.coder-hub.com/61573168.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定