最近项目中需要引入第三方的jar包,本人不想放入本地maven仓库中,使用一下方法,记录一下:
首先放入webapp下web_inf里的lib目录中(没有就创建)
然后在pom.xml文件中引入依赖
<dependency> <groupId>cn.gb</groupId> <artifactId>ShoppingMall</artifactId> <version>1.0</version> <scope>system</scope> <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/ZhenziSmsSDK.jar</systemPath> </dependency>
除了<scope> <systemPath> 标签,其他标签里的值我乱填的
最后在<plugin>里找到<artifactId>值为
maven-compiler-plugin
加入一段配置
<configuration> <source>1.8</source> <target>1.8</target> <compilerArguments> <extdirs>${basedir}/src/main/webapp/WEB-INF/lib</extdirs> </compilerArguments> </configuration>
就是这样
这里的作用是在项目打包,发布到tomcat的时候,也打包lib目录里的第三方jar.
避免出现ClassNotFound