Mavenにプロジェクト依存のjarをWEB-INF / libディレクトリにコピーさせて解決する方法(目標 'copy-dependencies'、 'unpack')



How Make Maven Copy Project Dependent Jar Web Inf Lib Directory



注:パッケージはラップされます。maven-dependency-plugin(goals copy-dependencies unpack)はm2e例外問題でサポートされていません。

org.eclipse.m2e lifecycle-mapping 1.0.0 org.apache.maven.plugins maven-dependency-plugin [2.0,) copy-dependencies

1.デフォルトのライフサイクルのコンパイルフェーズでmaven-dependency-plugin:copy-dependenciesコマンドを実行します。


org.apache.maven.plugins
maven-依存関係-プラグイン


コピー依存関係
パッケージ

コピー依存関係


$ {project.build.directory} / lib
false
true






2.依存関係jarパッケージが変更されたら、クリーンライフサイクルを実行し、古いjarパッケージをすべて削除する必要があります。これにより、WEB-INF / libおよびMavenの依存関係がJarパッケージと一致するようになります。 。

org.apache.maven.plugins
maven-clean-plugin


掃除
プレクリーニング

掃除


src / main / webapp / WEB-INF / lib





プロジェクトパス:

$ {project.build.directory}



別の方法:

まず、デフォルトのディレクトリtarged / dependencyにエクスポートします

Export the jar package dependencies from the Maven project: Go to the directory where the project pom.xml is located and execute the following command:

mvn依存関係:コピー依存関係



Or in eclipse, select the project's pom.xml file, click Run As in the right-click menu, see the red box below, in the pop-up Configuration window, enter the dependency: copy-dependencies, click Run The jar packages that the maven project depends on are exported to the targed/dependency directory.

次に、カスタムディレクトリにエクスポートします

Create a lib folder under the maven project and enter the following command:

mvnの依存関係:copy-dependencies -DoutputDirectory = lib

The jar package that the maven project depends on will be copied to the lib directory under the project directory.

第三に、依存関係レベルを設定します

You can also set the dependency level, usually using the compile level.

mvnの依存関係:copy-dependencies -DoutputDirectory = lib -DincludeScope = compile