
1. 概述
在正常开发中,由于各种原因,某些Jar包未包含在Maven的中央存储库中,因此必须在本地添加.
2. 复制到项目根目录

项目根目录与pom.xml文件位于同一目录. 您可以在项目根目录下创建一个文件夹libmaven安装jar包,如下所示:

这四个Jar包是识别网页编码所必需的.

3. 配置pom.xml,依靠本地Jar
配置Jar的依赖项,包括三个属性groupId,artifactId,version,还包括scope和systemPath属性. 从本地文件和本地文件的路径中指定Jar包.
<!-- ################################# cpdetector #################################### -->
<dependency>
<groupId>cpdetector</groupId>
<artifactId>cpdetector</artifactId>
<version>1.0.10</version>
<scope>system</scope>
<systemPath>${basedir}/lib/cpdetector_1.0.10.jar</systemPath>
</dependency>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.4</version>
<scope>system</scope>
<systemPath>${basedir}/lib/antlr-2.7.4.jar</systemPath>
</dependency>
<dependency>
<groupId>chardet</groupId>
<artifactId>chardet</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/lib/chardet-1.0.jar</systemPath>
</dependency>
<dependency>
<groupId>jargs</groupId>
<artifactId>jargs</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/lib/jargs-1.0.jar</systemPath>
</dependency>

其中$ {basedir}是项目的根路径
4. 配置Maven插件以将本地Jar打包到War中
在完成上述配置之后maven安装jar包,可以在编写代码时引入Jar包中的类,但是在打包时,由于scope = system,默认情况下,war包中将不包括Jar包,因此都需要通过插件Bale完成.

修改pom.xml文件,并在plugins标签下添加以下代码
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>compile</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/lib</outputDirectory>
<includeScope>system</includeScope>
</configuration>
</execution>
</executions>
</plugin>
通过这种方式,war软件包将包含本地导入的jar依赖项.
以上是本文的全部内容. 希望对大家的学习有所帮助. 我也希望每个人都支持该脚本主页.
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/shouji/article-162469-1.html
1937年中国的人口远超鬼子多少