I have a similar issue today, and stuck me half day to fix it.
For most case, using below is fine for developing.
<dependency>
<groupId>com.netease</groupId>
<artifactId>thrift</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/prome-thrift-client-1.0.0.jar</systemPath>
</dependency>
If you put the jar to a correct path, then it's fine to run in both IDEA and Eclipse.
After you deploy the jar to a server or run the jar locally, then it may throws ClassNotFoundException
.
If you are using spring-boot, you still need below plugin:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
After run mvn clean package
, then you can find the jar under /BOOT_INF/lib
.
Between, if your package is war, then you still need this plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>lib</directory>
<targetPath>BOOT-INF/lib/</targetPath>
<!-- <targetPath>WEB_INF/lib/</targetPath> just for none spring-boot project -->
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
-----------------Another Way--------------------
You can using this plugin to replace maven-war-plugin
:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArguments>
<extdirs>${project.basedir}/lib</extdirs>
</compilerArguments>
</configuration>
</plugin>
And add the resource:
<resources>
<resource>
<directory>lib</directory>
<targetPath>BOOT-INF/lib/</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<targetPath>BOOT-INF/classes/</targetPath>
</resource>
</resources>