zoukankan      html  css  js  c++  java
  • 关于maven 把插件依赖一起打包进jar问题

    今天在做storm on maven的时候发现要依赖到storm-hdfs的jar。自己又非常不想把乱七八糟的东西丢上自己的集群lib。于是就想maven 打包的时候把插件一块打包进jar。maven默认自己不会打包进jar,我只要把自己需要的打包进去就好了。

    走了不少弯路,现在记录一把,防止以后自己用到:

    我的pom.xml

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>storm.lesson</groupId>
    <artifactId>storm.lesson</artifactId>
    <version>0.0.1</version>
    <dependencies>
    <dependency>
    <groupId>org.apache.storm</groupId>
    <artifactId>storm-core</artifactId>
    <version>0.10.0</version>
    <scope>compile</scope>
    </dependency>
    <dependency>
    <groupId>org.apache.storm</groupId>
    <artifactId>storm-hdfs</artifactId>
    <version>0.10.0</version>
    <scope>compile</scope><!--需要打包进去的插件必须是编译级别-->
    </dependency>
    </dependencies>
    <build>
    <sourceDirectory>src/main/java</sourceDirectory>
    <plugins>
    <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.3</version>
    <configuration>
    <source>1.6</source>
    <target>1.6</target>
    </configuration>
    </plugin>

    <!--以下是要做进去的插件包-->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.1</version>
    <executions>
    <execution>
    <phase>package</phase>
    <goals>
    <goal>shade</goal>
    </goals>
    <configuration>
    <artifactSet>
    <includes>
    <include>org.apache.storm:storm-hdfs</include>
    </includes>
    </artifactSet>
    </configuration>
    </execution>
    </executions>
    </plugin>


    </plugins>
    </build>
    </project>

     打包完成后会发现依赖包的class会被一起被打进生intall jar包。(过程要注意的点有jdk jre级别问题,默认的m2如果不使用要删掉的问题等等,大多网上很容易找到答案就不一一记录了,还要注意自己的项目路径,编译过程不知道为什么有一次被自己换了路径,还原回来就好了)

  • 相关阅读:
    autoMapper dotnetcore webapi 自动添加映射 abp
    win10安装MongoDB提示 the domain,user name and/or password are incorrect. Remember to use "." for the domain if the account is on the local machine.
    webapi 重复提交问题
    webapi postman 415 错误
    sqlserver 更新通过 select 查询出的结果集
    2016-03至2016-08前端工作总结
    css笔记——css 实现自定义按钮
    javascript笔记——date以及datetime的比较
    node.js笔记——gulp
    javascript笔记——密码组合规则
  • 原文地址:https://www.cnblogs.com/yaohaitao/p/7255342.html
Copyright © 2011-2022 走看看