I hope someone can give me some hints on this one, because google ain't helped me too much. I want to download a jar from Artifactory, and run it from my java code, but I encounter some difficulties on this simple step.
this is the maven dependency that I cannot make work
With that dependency, Maven knows the groupId, artifactId and version of my java file. As for the Scope field, I saw that it can either be compile, provided, runtime, system or test.
That jar file represents another module, it's an application, which I want to handle from the code, I don't want any particular state for that file when I am building the project, I just want to download it, and to use it when I need it, but it has to be downloaded inside the current project. Right now, with that maven dependency, the jar file will be downloaded from Artifactory when I build the project, but in the end I get an error:
Caused by: org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'userManagerImpl' for bean class [com.cgm.user.impl.UserManagerImpl] conflicts with existing, non-compatible bean definition of same name and class [com.cgm.authentication.impl.UserManagerImpl]
So, Spring doesn't know what to choose; I think one solution will be to rename all the beans from the project, but I can't afford to do that.
Any suggestions?
Thanks a lot!
For what you indicate, the problem is because you have several bean of the same type.
You can use @Qualifier along with @Autowired. In fact spring will ask you explicitly select the bean if ambiguous bean type are found, in which case you should provide the qualifier
For Example in following case it is necessary provide a qualifier
@Component
@Qualifier("staff")
public Staff implements Person {}
@Component
@Qualifier("employee")
public Manager implements Person {}
@Component
public Payroll {
private Person person;
@Autowired
public Payroll(@Qualifier("employee") Person person){
this.person = person;
}
}
Another alternative is to use the @Qualifier annotation in the class definition if it is part of your project.