2017-07-02 138 views
0

不存在我需要添加一个罐子在公共区域条件不存在,我的Maven项目我一直在使用这样的系统范围:JBoss的Maven项目添加JAR在公共仓库

<dependency> 
    <groupId>test</groupId> 
    <artifactId>test</artifactId> 
    <version>X.Y.Z</version> 
    <scope>system</scope> 
    <systemPath>${user.home}/jars/my.jar</systemPath> 
</dependency> 

该解决方案的工作在本地机器罚款但不在远程服务器。当我谷歌,我发现系统范围是aleardy一个不好的做法,所以有另一种解决方案添加一个罐子项目?

回答

0

您有两种选择。

首先

<dependency> 
    <groupId>test</groupId> 
    <artifactId>test</artifactId> 
    <version>X.Y.Z</version> 
    <scope>system</scope> 
    <systemPath>${project.basedir}/src/main/resources/yourJar.jar</systemPath> 
</dependency> 

在本地资源库安装这个jar,它会被包含在建项目。 您可以在您添加JAR本地资源库是这样的:

mvn install:install-file 
    -Dfile=<path-to-file> 
    -DgroupId=<group-id> 
    -DartifactId=<artifact-id> 
    -Dversion=<version> 
    -Dpackaging=<packaging> 
    -DgeneratePom=true 

Where: <path-to-file> the path to the file to load 
    <group-id>  the group that the file should be registered under 
    <artifact-id> the artifact name for the file 
    <version>  the version of the file 
    <packaging>  the packaging of the file e.g. jar 

编辑你的pom.xml

<dependency> 
    <groupId>test</groupId> 
    <artifactId>test</artifactId> 
    <version>X.Y.Z</version> 
</dependency> 
相关问题