1、将jar添加到本地仓库的作法: 如下面pom.xml依赖的jar包为例: 实际项目中pom.xml依赖写法:html
dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>3.1.0.RELEASE</version> </dependency>
Maven 安装 JAR 包的命令是:spring
mvn install:install-file -Dfile=jar包的位置 -DgroupId=上面的groupId -DartifactId=上面的artifactId -Dversion=上面的version -Dpackaging=jar
例如个人这个spring-context-support-3.1.0.RELEASE.jar 文件放在了"D:\mvn"中 则命令为: mvn install:install-file -Dfile=D:\mvn\spring-context-support-3.1.0.RELEASE.jar -DgroupId=org.springframework -DartifactId=spring-context-support -Dversion=3.1.0.RELEASE -Dpackaging=jar 注意:任何路径和名称不要有中文和空格,以防出现莫名其妙的错误oracle
2、不讲jar包添加到本地仓库也可在maven工程中使用外部jar包的作法: 假设将包htmlparser.jar放入了项目下的lib目录中 : -> ${project}/lib/htmlparser.jar 则pom.xml文件中依赖能够以下:maven
<dependency> <groupId>com.htmlparser</groupId> <artifactId>htmlparser</artifactId> <version>2.0</version> <scope>system</scope> <systemPath>${project.basedir}/lib/htmlparser.jar</systemPath> </dependency>
mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.1.0 -Dpackaging=jar -Dfile=ojdbc6.jarcode