且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Maven:我可以只在罐子中打包依赖项(不带应用程序)吗?

更新时间:2022-06-18 03:51:37

我将创建一个pom.xml文件(包含所有必填字段,例如groupId,artifactId ...),然后将所有依赖项添加到此pom中,并添加这个pom的maven程序集插件.执行mvm assembly:single命令.将创建具有所有依赖项的jar.

I would create a pom.xml file (with all the required fields, like groupId, artifactId ...) add all the dependencies to this pom, and add maven assembly plugin to this pom. execute mvm assembly:single command. Your jar with all the dependencies will be created.

<build>
  <plugins>
    <plugin>
      <artifactId>maven-assembly-plugin</artifactId>
      <configuration>    
        <descriptorRefs>
          <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
      </configuration>
    </plugin>
  </plugins>
</build>