Using this configuration, it's easy to configure the Main-Class attribute of the JAR manifest: If we add this configuration to the single goal example above and rebuild, we will see an entry like this in the META-INF/MANIFEST.MF file of the resulting JAR: For more information on advanced configuration for the Assembly Plugin, see the Resources section. However, when I try to run this jar file I get "Could not find or load main class src.main.java.com.domain.Mainclass" (I have changed the name domain and MainClass for my company's privacy sake) I have searched for days and none of the obvious tips seem to work. If you're using one of the prefabricated assembly descriptors, you just tell it which one; if you're using a custom assembly descriptor, you give it the path to the descriptor. NOTE: Many other configuration options are available for the various mojos in the Assembly Plugin. You configure it as follows in your project's pom.xml: Note that the Assembly Plugin allows you to specify multiple descriptorRefs at once, to produce multiple types of assemblies in a single invocation. The assembly mojo forces a package phase build to execute, in order to guarantee the availability of project binaries. To accommodate this, the Assembly Plugin supports configuration of an element which is identical to that supported by the maven-jar-plugin (see Resources). Using this configuration, it's easy to configure the Main-Class attribute of the jar manifest: If we add this configuration to the attached mojo example above and rebuild, we will see an entry like this in the META-INF/MANIFEST.MF file of the resulting jar: For more information on advanced configuration for the Assembly Plugin, see the Resources section. For a maven S W project that features "jar" packaging, we can specify the main class for the MANIFEST.MF file by specifying it in our pom.xml, as shown here: In most cases, you'll want to make sure your assemblies are created as part of your normal build process. maven-assembly-plugin使用描述(拷自 maven-assembly-plugin 主页) The Assembly Plugin for Maven is primarily intended to allow users to aggregate the project output along with its dependencies, modules, site documentation, and other files into a single distributable archive. For more information, see the examples section or the plugin parameter documentation. At this point, the directory-oriented mojos - directory and directory-inline - do not support the configuration element. For more information on writing your own assembly descriptor, read the. The resultant jar is also called 'fat jar'. Because many assemblies will contain compiled classes and other binaries, it's reasonable to assume that the package phase will be required to ensure those binaries exist and have been tested. 现在在Java工程中使用Maven已经是非常常见的配置。而对于Maven工程默认产生的Jar却不是可执行的,尤其在你创建了一个桌面应用程序后,不能直接执行是致命的。于是在本文中,我简单记录下如何配置使得Maven工程构建产生可执行的Jar,这里主要就是对Main-Class和Class-Path的配置。 Note: Many other configuration options are available for the various goals in the Assembly Plugin. For the sake of clarity, we'll cover configuration before execution. To accommodate this, the Assembly Plugin supports configuration of an element which is identical to that supported by the maven-jar-plugin (see Resources ). 问题I have been trying for several days now to create an executable jar file for my muli-module maven project. Using this configuration, it's easy to configure the Main-Class attribute of the jar manifest: You can build an assembly directly by executing: When this build completes, you should see a file in the target directory with a name similar to the following: Notice the artifact classifier, between the end of the version and the beginning of the file extension, jar-with-dependencies. Unfortunately, this currently means that binding the assembly mojo to the default lifecycle will cause Maven to execute the build twice - once for the main process, and once again in a forked lifecycle which is spawned by the assembly mojo itself. Apache Software Foundation, For more information on writing your own assembly descriptor, read the. By contrast, the attached mojo assumes that the build has already produced project binaries or whatever else it needs prior to building the assembly itself. However, once you've created this self-contained jar, you will probably want the ability to execute it using the -jar JVM switch. © NOTE: Invoking the assembly and directory mojos will cause Maven to build the project using the normal lifecycle, up to the package phase. Getting started with the Assembly Plugin is pretty simple. Additionally, it's possible to specify a mixture of descriptors and descriptorRefs within the same configuration. [Java]Maven Assembly Pluginで実行可能(Executable)なjarを作成する 使い方 Javaプログラムをコマンドラインから実行するには、依存するライブラリを全てまとめて実行可能なjarファイル(Executable jar)を作るのが便利です。 Existe-t-il un moyen d'inclure toutes les dépendances DANS le jar généré en exécutant l'objectif jfx: jar pour le plugin javafx maven? To handle archiving this version of Maven Assembly Plugin uses Maven Archiver 3.5.0. At this point, only the jar and war assembly formats support the configuration element. However, once you've created this self-contained JAR, you will probably want the ability to execute it using the -jar JVM switch. In JavaS W, an executable jarW file specifies its main class in the MANIFEST.MF file in that jar file. In order for this discussion to be useful, it's critical to cover two topics: configuration of the plugin - both inside the POM and, where possible, from the command line - and the different execution styles. This document is intended to provide instructions for using the maven-assembly-plugin. This document is intended to provide instructions for using the maven-assembly-plugin. Maven assembly jar execution Could not find or load main class Caused by: java.lang.ClassNotFoundException. 2002-2006 Currently, there are two basic approaches to building assemblies: as a dedicated build action, or bound to a phase of the normal build lifecycle. Viewed 19 times 0. Note that a single invocation of the Assembly Plugin can actually produce assemblies from multiple descriptors, allowing you maximum flexibility to customize the suite of binaries your project produces. This is the id of the assembly descriptor used to create this artifact. Because they depend on correct binding to the lifecycle in order to gain access to the files required by your project assembly, the attached and directory-inline mojos require the user to have much more intimate knowledge of the build process. To bind the single goal to a project's build lifecycle, you can add this configuration (assuming you're using the jar-with-dependencies prefabricated descriptor): Then, to create a project assembly, simple execute the normal package phase from the default lifecycle: When this build completes, you should see a file in the target directory with a name similar to the following: Notice the artifact classifier, between the end of the version and the beginning of the file extension, jar-with-dependencies. Alternatively, we've created a custom assembly descriptor called src.xml in the src/assembly directory (see the Resources section for more information). In some cases, you may only want to create an assembly periodically; these mojos provide two ways to accomplish that goal. Spring-boot-maven-plugin> = 1.4.0 jar structure changes. Copyright ©2002–2020 In most cases, the single goal should be bound to the package phase of the build. Sauf si vous avez besoin du "maven-assembly-plugin" pour des raisons autres que le réglage de la mainClass, vous pouvez utiliser le " maven-jar-plugin ' plugin. This is handled by the assembly:single goal. 指定了Main-Class,有了依赖包,那么就可以直接通过java -jar xxx.jar运行jar包。 这种方式生成jar包有个缺点,就是生成的jar包太多不便于管理,下面两种方式只生成一个jar文件,包含项目本身的代码、资源以及所有的依赖包. Using this configuration, it's easy to configure the Main-Class attribute of the JAR manifest: If we want to create an assembly binary that includes our project's dependencies, we can take advantage of one of the Assembly Plugin's prefabricated descriptors, as follows: Note that the Assembly Plugin allows you to specify multiple descriptorRefs at once, to produce multiple types of assemblies in a single invocation. To accommodate this, the Assembly Plugin supports configuration of an element which is identical to that supported by the maven-jar-plugin (see Resources). The main advantage of producing an assembly in this way is to avoid producing it as part of your normal build process. Using this configuration, it's easy to configure the Main-Class attribute of the jar manifest: [...] [...] maven-assembly-plugin [...] … Now I get a ClassNotFoundException. In this case, assemblies won't be produced when the normal build is executed, only in special circumstances. This ensures the assembly archives are made available for installation and deployment, and that they are created during the release of your project. In this quick article we'll focus on packaging a Maven project into an executable Jar file.Usually, when creating a jar file, we want to execute it easily, without using the IDE; to that end, we'll discuss the configuration and pros/cons of using each of these approaches for creating the executable. In order for this discussion to be useful, it's critical to cover two topics: configuration of the plugin - both inside the POM and, where possible, from the command line - and the different execution styles. When the assembly is created it will use the assemblyId as the artifact's classifier and will attach the created assembly to the project and will be uploaded into the repository on an install and deploy goal. While it's possible to assign the single goal to any phase of the build lifecycle, you should be careful to make sure the resources included in your assembly exist before that assembly is created. The attached and directory-inline mojos are functional counterparts of the mojos discussed above, except that they are meant to bind into the default build lifecycle. I have a spring-boot project where all integration tests are in a separate module that launches the application module using spring-boot-maven-plugin during the integration-test phase and runs the package against it. The Apache Software Foundation. This construct worked fine until it was upgraded to 1.4.0.RELEASE. Active yesterday. All rights reserved. As you've no doubt noticed, the Assembly Plugin can be a very useful way to create a self-contained binary artifact for your project, among many other things. For the sake of clarity, we'll cover configuration before execution. I have been trying, for several days now, to create an executable jar file for my muli-module maven project, sadly I have had no luck on doing it. Note that a single invocation of the Assembly Plugin can actually produce assemblies from multiple descriptors, allowing you maximum flexibility to customize the suite of binaries your project produces. When the assembly is created it will use the assemblyId as the artifact's classifier and will attach the created assembly to the project so that it will be uploaded into the repository in the install and deploy phase. To handle filtering this version of Maven Assembly Plugin uses Maven Filtering 3.1.1.

Signs Film Stream, Die Siedler 4 Gold Edition, Biofilm Natürlich Entfernen, Flugzeug Spiele 3d, Der Einzig Wahre Ivan Trailer, Chadwick Boseman Freundin, John Niven Interview, Kopf Hoch Bilder Für Whatsapp, Demonstrativpronomen Französisch übungen Zum Ausdrucken, Extrem Sauber Ganze Folgen Kostenlos, Vanille Aussprache Deutsch,