Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle 2 imports with the same name using Spring

Artemy Matvienko
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2018

I'm trying to follow this outdated tutorial. It's making use of the sal and jira versions of the UserManager. The differentiation they use doesn't seem to work with Spring's annotations. 

import com.atlassian.sal.api.user.UserManager;

@Component
public class TestClass extends HttpServlet{
@ComponentImport
private UserManager userManager;

private com.atlassian.jira.user.util.UserManager jiraUserManager;

@Autowired
public TestClass(UserManager userManager, com.atlassian.jira.user.util.UserManager jiraUserManager) {
this.userManager = userManager;
this.jiraUserManager = jiraUserManager;
}

}

This is stripped down version of what I have. (see the repo for full code)

The error I'm getting is:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.atlassian.jira.user.util.UserManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}

Any help would be appreciated in resolving this issue.

1 answer

0 votes
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2018

You also have to use @ComponentImport for the second bean.

Artemy Matvienko
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 18, 2018

The problem is that I get the exact same error regardless of whether @ComponentImport is present above

private com.atlassian.jira.user.util.UserManager jiraUserManager;   

 or not. 

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 18, 2018

I think I would need an example from you to see, what is going on in your plugin. It would be nice to have it on bitbucket or github

Artemy Matvienko
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 18, 2018

I've uploaded it to github:

https://github.com/Cohaven/version-control

Artemy Matvienko
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 20, 2018

@Alexey Matveev Any thoughts?

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 20, 2018

This a plugin for Spring scanner 1x. It seems, that you wrote everything correctly. I need more time to dig dipper, but unfortunately, I do not have time right now for it.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events