i come across problems packing uber jar, in spring-boot
parent pom,i defined project dependency this:
<dependencymanagement> <dependencies> <!--import spring-boot--> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-dependencies</artifactid> <version>${spring.boot.version}</version> <type>pom</type> <scope>import</scope> <exclusions> <exclusion> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-logging</artifactid> </exclusion> <exclusion> <groupid>org.slf4j</groupid> <artifactid>log4j-over-slf4j</artifactid> </exclusion> </exclusions> </dependency> <!--spring boot package war--> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-degacy</artifactid> <version>${spring-boot-legacy.version}</version> </dependency> <!--log compoment--> <dependency> <groupid>cn.migu</groupid> <artifactid>logutils</artifactid> <version>1.0</version> </dependency> <dependency> <groupid>commons-lang</groupid> <artifactid>commons-lang</artifactid> <version>2.7-snapshot</version> </dependency> <!--oracle jdbc6--> <dependency> <groupid>com.hynnet</groupid> <artifactid>oracle-driver-ojdbc6</artifactid> <version>12.1.0.1</version> </dependency> </dependencies> </dependencymanagement>
and create new sub project ,and defined dependency this
<dependencies> <!-- spring boot --> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-web</artifactid> <exclusions> <exclusion> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-logging</artifactid> </exclusion> </exclusions> </dependency> <!-- spark --> <dependency> <groupid>org.apache.spark</groupid> <artifactid>spark-core_${scala.binary.version}</artifactid> <scope>provided</scope> </dependency> <dependency> <groupid>org.apache.spark</groupid> <artifactid>spark-sql_${scala.binary.version}</artifactid> <scope>provided</scope> </dependency> <dependency> <groupid>org.apache.spark</groupid> <artifactid>spark-hive_${scala.binary.version}</artifactid> <scope>provided</scope> </dependency> <dependency> <groupid>org.apache.spark</groupid> <artifactid>spark-mllib_${scala.binary.version}</artifactid> <scope>provided</scope> </dependency> <!-- dubbo --> <dependency> <groupid>com.alibaba</groupid> <artifactid>dubbo</artifactid> <exclusions> <exclusion> <groupid>org.springframework</groupid> <artifactid>spring</artifactid> </exclusion> </exclusions> </dependency> <dependency> <groupid>com.github.sgroschupf</groupid> <artifactid>zkclient</artifactid> <exclusions> <exclusion> <groupid>log4j</groupid> <artifactid>log4j</artifactid> </exclusion> </exclusions> </dependency> <dependency> <groupid>cn.migu</groupid> <artifactid>interface</artifactid> <version>1.0</version> </dependency> <dependency> <groupid>cn.migu</groupid> <artifactid>sparkjobserver-common</artifactid> <version>1.0</version> <exclusions> <exclusion> <groupid>org.apache.spark</groupid> <artifactid>*</artifactid> </exclusion> <exclusion> <groupid>mysql</groupid> <artifactid>mysql-connector-java</artifactid> </exclusion> </exclusions> </dependency> </dependencies>
when use command below, there no dependency cn.migu.logutil
component in new sub project.
mvn dependency:tree -dverbose
then use maven-shade-plugin package uber jar, , run:
mvn clean package
.. wrong this:
[info] including cn.migu:logutils:jar:1.0 in shaded jar. [info] including commons-lang:commons-lang:jar:2.7-snapshot in shaded jar
these 2 jars had never import new sub project. there wrong config, or shade-plugin?
the shade plugin config is:
<plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-shade-plugin</artifactid> <version>2.4.3</version> <dependencies> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-maven-plugin</artifactid> <version>${springboot.version}</version> </dependency> </dependencies> <configuration> <filters> <filter> <artifact>*:*</artifact> <excludes> <exclude>meta-inf/*.sf</exclude> <exclude>meta-inf/*.dsa</exclude> <exclude>meta-inf/*.rsa</exclude> </excludes> </filter> </filters> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.appendingtransformer"> <resource>meta-inf/spring.handlers</resource> </transformer> <transformer implementation="org.springframework.boot.maven.propertiesmergingresourcetransformer"> <resource>meta-inf/spring.factories</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.appendingtransformer"> <resource>meta-inf/spring.schemas</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.servicesresourcetransformer" /> <transformer implementation="org.apache.maven.plugins.shade.resource.manifestresourcetransformer"> <mainclass>cn.migu.sparkjobserver.server.java.bootapplication</mainclass> </transformer> </transformers> </configuration> </execution> </executions> </plugin>
Comments
Post a Comment