繁体   English   中英

有没有办法将公共jar URL作为Maven依赖项包括在内?

[英]Is there a way to include a public jar URL as a maven dependency?

我有一个在S3上公开托管的jar文件。 我想将其包含在另一个Maven Java项目中。

我可以将它作为依赖项包含在pom.xml中吗?

如果文件结构遵循Maven文件夹结构,则只需指定

    <repositories>
        <repository>
            <id>example-repo</id>
            <url>https://your_website/path</url>
        </repository>
    </repositories>

如果您只想链接jar,则需要使用下载插件https://github.com/maven-download-plugin/maven-download-plugin将jar下载到lib文件夹

<plugin>
    <groupId>com.googlecode.maven-download-plugin</groupId>
    <artifactId>download-maven-plugin</artifactId>
    <version>1.4.2</version>
    <executions>
        <execution>
            <id>install-jbpm</id>
            <phase>compile</phase>
            <goals>
                <goal>wget</goal>
            </goals>
            <configuration>
                <url>http://path_to_your_jar</url>
                <outputDirectory>${project.build.directory}
            </configuration>
        </execution>
    </executions>
</plugin>

然后用

 <dependency>
    <groupId>com.sample</groupId>
    <artifactId>sample</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/yourJar.jar</systemPath>
</dependency>
<dependency> <groupId>com.xxx.xxx</groupId> <artifactId>example-app</artifactId> <version>1.0</version> <scope>system</scope> <systemPath>${basedir}/lib/yourJar.jar</systemPath> </dependency>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM