首页 > maven仓库搜不到我想要的jar怎么办?这时pom.xml的dependencies怎么写?

maven仓库搜不到我想要的jar怎么办?这时pom.xml的dependencies怎么写?

我想要PHP/Java Bridge技术的JavaBridge.jar放到pom.xml里管理起来,里面class文件的包名我都知道,xml怎么写?


例如:
1)直接放到工程的目录中

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
        <version>1.1.1</version>
        <scope>system</scope>
        <!--本地jar的路径,相对或者绝对都可以-->
        <systemPath>path/to/yourLocalJar.jar</systemPath>
</dependency>

2)有条件可以自己搭建nexus私服,将该jar包上传至nexus服务器
上传jar包到nexus私服


本地包也是可以的,配置成本地包即可。


可以把jar包安装到本地仓库
mvn install:install-file -DgroupId=com.xxx -DartifactId=yyy -Dversion=1.0.0 -Dpackaging=jar -Dfile=JavaBridge.jar

pom.xml里就可以配置dependency了

对应的groupId是com.xxx
artifactId是yyy
version是1.0.0


自定义jar包


<dependencies>
    <dependency>
        <groupId>{groupId}</groupId>
        <artifactId>{artifactId}</artifactId>
        <version>{version}</version>
    </dependency>
</dependencies>

Maven是根据groupId、artifactId和version作为坐标来定位的,所以要填上这三个配置项。

【热门文章】
【热门文章】