3

I have a common library published on nexus that has package id

x.xx.common

it contains sub packages of common feign clients proxy interfaces

The project that uses this library has package id.

x.xx.account 
x.xx.device

each of these projects has its application class in the root

x.xx.account.AppClass
x.xx.device.AppClass

each of these class has

@SpringBootApplication(scanBasePackages = {"x.xx"})

for some reason both projects don't see any of the proxy interfaces under subpackages

x.xx.common.proxy
x.xx.common.configuration

I tried moved the proxy interfaces directly under main package

x.xx.common

but it also failed

Parameter 0 of constructor in x.xx.common.service.impl.AuditServiceImpl required a bean of type 'x.xx.common.LogProxy' that could not be found.

that error is given for every interface proxy

Mo Adel
  • 1,136
  • 1
  • 16
  • 29

2 Answers2

3

Add annotation to your sub packages class which you want to be scanned. Add the annotations like @Component, @Service or @Repository respectively to the class respectively. For the annotation: @SpringBootApplication(scanBasePackages = {"x.xx"})

Suppose there is a class named Abc in the subpackage x.xx, so add the annotation @Component to the class.

@Component class Abc{}

This will help to read the sub packages class.

To know more about the difference between the above mention annotations: What's the difference between @Component, @Repository & @Service annotations in Spring?

Bishal Jaiswal
  • 1,684
  • 13
  • 15
0

I have figured it out, apparently the AppClass @EnableFeignClients need to have the base class added to it as well.

So for anyone that has the same problem my AppClass now has the following annotation

@SpringBootApplication(scanBasePackages = {"x.xx"})
@EnableFeignClients(basePackages= {"x.xx"})
public class AppClass {
}
Mo Adel
  • 1,136
  • 1
  • 16
  • 29