The assembly plugin is used to import the jar package that is not in the maven library into the runnable jar package

1. Add <scope>provided</scope> to dependency
2. Add <artifactId>maven-assembly-plugin</artifactId> plugin
3. Run through maven command: mvn assembly:assembly

<dependencies>

      <!-- Add UserAgent dependency-->
      <dependency>
          <groupId>com.kumkee</groupId>
          <artifactId>UserAgentParser</artifactId>
          <version>0.0.1</version>
          <scope>provided</scope>
      </dependency>

      <!--Add Hadoop dependency-->
      <dependency>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-client</artifactId>
          <version>${hadoop.version}</version>
      </dependency>

      <!--Add unit test dependencies-->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.10</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

    <!-- mvn assembly:assembly -->
  <build>
      <plugins>
          <plugin>
              <artifactId>maven-assembly-plugin</artifactId>
              <configuration>
                  <archive>
                      <manifest>
                          <mainClass></mainClass>
                      </manifest>
                  </archive>
                  <descriptorRefs>
                      <descriptorRef>jar-with-dependencies</descriptorRef>
                  </descriptorRefs>
              </configuration>
          </plugin>
      </plugins>
  </build>

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326644801&siteId=291194637