Loading feignClient from jar package

  springboot, springcloud

Problem

Some common components extract maven dependencies of other modules. At this time, it is not enough to only rely on @ComponentScan to load spring component and feign components of this jar package in the project in use. basekPackages must also be marked in @ EnableFeign Clients (BasePackages = {“com.xixicat”}).

For maven compilation

If configured in parent

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

Then if the component does not have main class, the repackage here cannot pass, and you need to skip it in maven of the component.

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>

docs