打maven包及引入本地jar包

在maven开发中,一般情况下需要从maven仓库中下载jar包,仅需要在pom.xml文件中进行配置即可,但某些情况下,maven仓库不由自己管理,没有包含需要用到的jar包,此时就需要在项目中自己引入jar包。步骤如下:
1、在根目录下新建一个文件夹;
2、在pom文件中对项目文件进行绝对引用;

举例如下:
比如需要在项目中引入struts单元测试相关包,可以在maven中进行如下配置:

<!-- 单元测试专用 -->
		<dependency> 
		    <groupId>cn.mamp</groupId> 
		    <artifactId>jsp-api</artifactId> 
		    <version>2.0</version> 
		    <type>jar</type> 
		    <scope>system</scope> 
		    <systemPath>${basedir}/junitlib/jsp-api-2.0.jar</systemPath> 
		</dependency>
		<dependency> 
		    <groupId>cn.mamp</groupId> 
		    <artifactId>spring-test</artifactId> 
		    <version>3.0.5</version> 
		    <type>jar</type> 
		    <scope>system</scope> 
		    <systemPath>${basedir}/junitlib/spring-test-3.0.5.RELEASE.jar</systemPath> 
		</dependency>
		<dependency> 
		    <groupId>cn.mamp</groupId> 
		    <artifactId>struts2-junit</artifactId> 
		    <version>2.3.32</version> 
		    <type>jar</type> 
		    <scope>system</scope> 
		    <systemPath>${basedir}/junitlib/struts2-junit-plugin-2.3.32.jar</systemPath> 
		</dependency>
		<!-- 单元测试专用 -->


maven内置变量说明:
  • ${basedir} 项目根目录
  • ${project.build.directory} 构建目录,缺省为target
  • ${project.build.outputDirectory} 构建过程输出目录,缺省为target/classes
  • ${project.build.finalName} 产出物名称,缺省为${project.artifactId}-${project.version}
  • ${project.packaging} 打包类型,缺省为jar
  • ${project.xxx} 当前pom文件的任意节点的内容

猜你喜欢

转载自liushuiwuyan.iteye.com/blog/2379022