Instantiate NavBuilder

Hello. I am trying to retrieve a pull request url and I saw the NavBuilder interface would be useful for that. I’m struggling to instantiate a class that implements this interface though.
I imported the bitbucket-server-api and spi packages in my pom.xml. I’m probably not giving enough information because I’m new developing bitbucket-plugins.
I’ll provide a code snippet so that you understand my idea.

String content = String.format(“Branch "%s" was merged into branch "%s" at %s. Details at %s”, fromBranch, toBranch, event.getDate().toString(), url);

I’d set the url with the buildAbsolute() for the specific pullRequest.
I tried using

@ComponentImport
NavBuilder nb;

or

@Autowired
NavBuilder nb;

But none of them worked. There were exceptions telling me no bean implementing NavBuilder was available.
What are the steps to be followed to obtain an instance of NavBuilder or its nested classes (e.g. NavBuilder.PullRequestOverview, …)?

The NavBuilder needs to be imported as a component. In general there are 3 ways to do this, depending on which way you use in your plugin it might be different.

You need a <component-import> element in your atlassian-plugin.xml, or you have to define a <osgi:import> element in your META-INF/spring/component-imports.xml file.

Or you can use this method: https://developer.atlassian.com/server/framework/atlassian-sdk/spring-java-config/