> For the complete documentation index, see [llms.txt](https://divine.qibergames.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://divine.qibergames.com/advanced-usage/openapi/referenced-dependency-access.md).

# Referenced dependency access

One workaround for circular dependency access, is to use `Ref`s. A `Ref<T>` features lazy access to a dependency.

```java
@Service
class ServiceA {
    Ref<ServiceB> serviceB;
    
    void foo() {
        serviceB.get().baz();
    }
    
    void bar() {
        System.out.println("Hello!");
    }
}

@Service
class ServiceB {
    Ref<ServiceA> serviceA;
    
    void baz() {
        serviceA.get().bar();
    }
}

void useCircularRefs() {
    Container.get(ServiceA.class).foo(); // will print `Hello!`
}
```
