2016-07-29 7 views
0

私は外部jarを含む実行可能なjarファイルを作成しようとしています。 私はすでに、私は以下を使用する必要があり、この外部jarファイルを、下記の記事を読んで、私の場合でいる: #MYGROUP# #myArtifact# #バージョン# システム $ {project.basedir}/libに/#myjar#.jar systemPathのため、スコープシステムを使用する必要があります。そのため、私の最終的な実行可能なjarファイルには私のjarファイルが含まれません。 私のjarファイルを実行しようとすると、そのファイルはNoClassDefFoundErrorで外部のjarファイルになります。 最終的な実行可能なjarに外部jarを含める方法を教えてください。maven外部ライブラリを使ってfat jarを作成します

Here is my current plugins: 
<!-- compiler plugin --> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>2.3.2</version> 
       <configuration> 
        <source>${jdk.version}</source> 
        <target>${jdk.version}</target> 
       </configuration> 
      </plugin> 

      <!-- Make this jar executable --> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-jar-plugin</artifactId> 
       <configuration> 
        <archive> 
         <manifest> 
          <addClasspath>true</addClasspath> 
          <mainClass>#MYMAINCLASS#</mainClass> 
          <classpathPrefix>lib/</classpathPrefix> 
         </manifest> 
        </archive> 
       </configuration> 
      </plugin> 

      <!-- Copy project dependency , can be used when we have repository.--> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-dependency-plugin</artifactId> 
       <version>2.5.1</version> 
       <executions> 
        <execution> 
         <id>copy-dependencies</id> 
         <phase>prepare-package</phase> 
         <goals> 
          <goal>copy-dependencies</goal> 
         </goals> 
         <configuration> 
<outputDirectory>${project.build.directory}/lib</outputDirectory> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 

Thanks you answer in advance! 

http://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven 
https://www.mkyong.com/maven/create-a-fat-jar-file-maven-assembly-plugin/ 

答えて

0

外部のjarを手動でリポジトリにインストールしてから、デフォルトのスコープでjarを使用すると、最も簡単な解決策になります。

mvn install:install-file -Dfile=<path-to-file> \ 
         -DgroupId=<myGroup> \ 
         -DartifactId=<myArtifactId> \ 
         -Dversion=<myVersion> \ 
         -Dpackaging=<myPackaging> 

そして、あなたはまた、here

可能性、他のオプションを参照することができます
関連する問題