maven assemby 打包问题

注意几点问题:

1.packaging应该为jar,不是war

2.打包之前先编译compile

3.出问题看warning和error提示

 

附示例

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>testhbaseha</groupId>
  <artifactId>testhbaseha</artifactId>
  <packaging>jar</packaging>
  <version>1.1-SNAPSHOT</version>
  <name>testhbaseha</name>

    <repositories>
        <repository>
            <id>repo1</id>
            <name>repo1</name>
            <url>http://repo1.maven.org/maven2/</url>
        </repository>

        <repository>
            <id>cloudera</id>
            <url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
        </repository>

        <repository>
            <id>sinadb</id>
            <name>Sina DataPlatform Repositories</name>
            <url>http://10.55.28.58:8081/nexus/content/groups/public/</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>apache.snapshots</id>
            <name>Apache Snapshots</name>
            <url>http://repository.apache.org/content/groups/snapshots-group/</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

    <properties>
        <fastjson.version>1.1.36</fastjson.version>
        <spring.version>3.2.0.RELEASE</spring.version>
        <curator.version>1.3.3</curator.version>
        <httpclient.version>4.2.5</httpclient.version>
        <jedis.version>2.2.0-SNAPSHOT</jedis.version>
        <hbase.version>0.96.0-hadoop2</hbase.version>
        <hadoop.version>2.2.0</hadoop.version>
        <mysql.connector.version>5.1.24</mysql.connector.version>
        <antlr.version>3.5</antlr.version>
        <gson.version>2.2.3</gson.version>
        <javax.servlet.version>2.5</javax.servlet.version>
        <javax.servlet.jsp.version>2.1</javax.servlet.jsp.version>
        <junit.version>4.8.2</junit.version>
        <jsoup.version>1.7.2</jsoup.version>
        <json-lib.version>2.2.3</json-lib.version>
        <commons-cli.version>1.2</commons-cli.version>
        <commons-fileupload.version>1.3</commons-fileupload.version>
    </properties>

  <dependencies>
      <dependency>
          <groupId>com.google.code.findbugs</groupId>
          <artifactId>annotations</artifactId>
          <version>1.3.9</version>
      </dependency>

      <dependency>
          <groupId>org.apache.hbase</groupId>
          <artifactId>hbase-server</artifactId>
          <version>0.96.1.1-hadoop2</version>
      </dependency>

      <dependency>
          <groupId>org.apache.hbase</groupId>
          <artifactId>hbase-client</artifactId>
          <version>0.96.1.1-hadoop2</version>
      </dependency>

      <dependency>
          <groupId>redis.clients</groupId>
          <artifactId>jedis</artifactId>
          <version>2.2.0-SNAPSHOT</version>
      </dependency>

      <dependency>
          <groupId>commons-pool</groupId>
          <artifactId>commons-pool</artifactId>
          <version>1.5.5</version>
      </dependency>

      <dependency>
          <groupId>org.apache.hbase</groupId>
          <artifactId>hbase-common</artifactId>
          <version>0.96.1-hadoop2</version>
      </dependency>






      <!--<dependency>-->
          <!--<groupId>org.apache.httpcomponents</groupId>-->
          <!--<artifactId>httpclient-cache</artifactId>-->
          <!--<version>${httpclient.version}</version>-->
      <!--</dependency>-->
      <!--<dependency>-->
          <!--<groupId>org.apache.httpcomponents</groupId>-->
          <!--<artifactId>httpclient</artifactId>-->
          <!--<version>${httpclient.version}</version>-->
      <!--</dependency>-->
      <!--<dependency>-->
          <!--<groupId>com.google.code.gson</groupId>-->
          <!--<artifactId>gson</artifactId>-->
          <!--<version>${gson.version}</version>-->
      <!--</dependency>-->
      <!--<dependency>-->
          <!--<groupId>org.antlr</groupId>-->
          <!--<artifactId>antlr</artifactId>-->
          <!--<version>${antlr.version}</version>-->
      <!--</dependency>-->
      <!--<dependency>-->
          <!--<groupId>net.sf.json-lib</groupId>-->
          <!--<artifactId>json-lib</artifactId>-->
          <!--<version>${json-lib.version}</version>-->
          <!--<classifier>jdk15</classifier>-->
      <!--</dependency>-->
      <!--<dependency>-->
          <!--<groupId>commons-cli</groupId>-->
          <!--<artifactId>commons-cli</artifactId>-->
          <!--<version>${commons-cli.version}</version>-->
      <!--</dependency>-->
      <!--<dependency>-->
          <!--<groupId>net.sf.ezmorph</groupId>-->
          <!--<artifactId>ezmorph</artifactId>-->
          <!--<version>1.0.6</version>-->
      <!--</dependency>-->
      <!--<dependency>-->
          <!--<groupId>commons-collections</groupId>-->
          <!--<artifactId>commons-collections</artifactId>-->
          <!--<version>3.2.1</version>-->
      <!--</dependency>-->
      <!--<dependency>-->
          <!--<groupId>commons-beanutils</groupId>-->
          <!--<artifactId>commons-beanutils</artifactId>-->
          <!--<version>1.8.3</version>-->
      <!--</dependency>-->


      <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.10</version>
      <scope>test</scope>
    </dependency>
  </dependencies>


  <build>
    <finalName>testhbaseha</finalName>
      <plugins>
          <plugin>
              <artifactId>maven-assembly-plugin</artifactId>
              <version>2.4</version>
              <configuration>
                  <descriptorRefs>
                      <descriptorRef>jar-with-dependencies</descriptorRef>
                  </descriptorRefs>
                  <archive>
                      <manifest>
                          <mainClass>cn.com.sina.xrtest.MainCp</mainClass>
                      </manifest>
                  </archive>
              </configuration>
          </plugin>
          <plugin>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>3.1</version>
              <configuration>
                  <encoding>UTF-8</encoding>
                  <source>1.6</source>
                  <target>1.6</target>
              </configuration>
          </plugin>
          <plugin>
              <artifactId>maven-surefire-plugin</artifactId>
              <version>2.16</version>
              <configuration>
                  <includes>
                      <include>**/*Tests.java</include>
                  </includes>
              </configuration>
          </plugin>

          <!--<plugin>-->
              <!--<groupId>org.apache.tomcat.maven</groupId>-->
              <!--<artifactId>tomcat7-maven-plugin</artifactId>-->
              <!--<version>2.1</version>-->
              <!--<configuration>-->
                  <!--<url>http://10.73.13.99:8888/dataplatform</url>-->
                  <!--<username>xinrong3</username>-->
                  <!--<password>123</password>-->
                  <!--<server>tomcat</server>-->
                  <!--<update>true</update>-->
                  <!--<path>/</path>-->
              <!--</configuration>-->
              <!--<executions>-->
                  <!--<execution>-->
                      <!--<id>tomcat-deploy</id>-->
                      <!--<phase>deploy</phase>-->
                      <!--<goals>-->
                          <!--<goal>deploy</goal>-->
                      <!--</goals>-->
                  <!--</execution>-->
              <!--</executions>-->
          <!--</plugin>-->

      </plugins>

  </build>
</project>

 

posted @ 2014-03-20 12:03  D调的晨星  阅读(412)  评论(0编辑  收藏  举报