一、手动添加Jar包
1、项目引入本地jar包
2、引入本地jar包后项目编译正常
3、maven打包时报错
解决
在pom.xml
的plugins
添加以下配置
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<!--配置本地jar包在项目的存放路径-->
<compilerArguments>
<extdirs>${project.basedir}/lib</extdirs>
</compilerArguments>
</configuration>
</plugin>
二、使用systemPath标签引入Jar包
1、使用systemPath标签引入本地依赖
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-sql-parser-binder</artifactId>
<version>4.1.1</version>
<systemPath>${project.basedir}/lib/apache-shardingsphere-binder-4.1.1.jar</systemPath>
<scope>system</scope>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>apache-shardingsphere-common</artifactId>
<version>4.1.1</version>
<systemPath>${project.basedir}/lib/apache-shardingsphere-common-4.1.1.jar</systemPath>
<scope>system</scope>
</dependency>
2、即使添加以下配置依赖还是无法打包
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<!--配置本地jar包在项目的存放路径-->
<compilerArguments>
<extdirs>${project.basedir}/lib</extdirs>
</compilerArguments>
</configuration>
</plugin>
解决
手动添加到WEB-INF/lib目录(缺点是其他开发人员如果忘记次操作,打包时会缺少相应Jar包)