1, a new directory in the jar src / main / resource, the outer bag on the directory jar
2, adding a dependency in pom.xml
groupId, artifactId, version can easily write
<dependency> <groupId>com.huawei</groupId> <artifactId>gsjdbc4</artifactId> <version>1.0</version> <scope>system</scope> <systemPath>${basedir}/src/main/resources/jar/gsjdbc4.jar</systemPath> </dependency> <dependency> <groupId>com.huawei</groupId> <artifactId>gsjdbc200</artifactId> <version>1.0</version> <scope>system</scope> <systemPath>${basedir}/src/main/resources/jar/gsjdbc200.jar</systemPath> </dependency>
At this, local access is not a problem to start the project, but the packaging, then it will error, the following steps
3, pom.xml increased plugin configuration
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <webResources> <resource> <directory>src/main/resources/jar/</directory> <targetPath>WEB-INF/lib/</targetPath> <includes> <include>**/*.jar</include> </includes> </resource> </webResources> </configuration> </plugin>
然后再打包即可
4,遇到的问题
打包时报错: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)
原因: maven 插件 maven-war-plugin 中 Servlet 版本太低,要求必须要有web.xml文件才行
解决方法: 把plugin配置里面的<version>2.4</version>去掉,再次打包即可