2016-02-12 210 views
-3

我正在嘗試創建Web應用程序的jar文件。但它正在創建war文件還only.I更新<packaging>jar</packaging>無法使用maven創建Web應用程序的jar文件

但不工作

POM

<?xml version="1.0"?> 
<project 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" 
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>XertoPublicApp</groupId> 
    <artifactId>XertoPublicApp</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>jar</packaging> 
    <dependencies> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>servlet-api</artifactId> 
      <version>2.5</version> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet.jsp</groupId> 
      <artifactId>jsp-api</artifactId> 
      <version>2.1</version> 
      <scope>provided</scope> 
     </dependency> 

     <repositories> 
     <repository> 
      <snapshots> 
       <enabled>false</enabled> 
      </snapshots> 
      <id>central</id> 
      <name>Central Repository</name> 
      <url>http://repo.maven.apache.org/maven2</url> 
     </repository> 
    </repositories> 
    <pluginRepositories> 
     <pluginRepository> 
      <releases> 
       <updatePolicy>never</updatePolicy> 
      </releases> 
      <snapshots> 
       <enabled>false</enabled> 
      </snapshots> 
      <id>central</id> 
      <name>Central Repository</name> 
      <url>http://repo.maven.apache.org/maven2</url> 
     </pluginRepository> 
    </pluginRepositories> 
    <build> 
     <sourceDirectory>C:\Users\musaddique\workspace\XertoPublicApp\src</sourceDirectory> 
     <scriptSourceDirectory>C:\Users\musaddique\workspace\XertoPublicApp\src\main\scripts</scriptSourceDirectory> 
     <testSourceDirectory>C:\Users\musaddique\workspace\XertoPublicApp\src\test\java</testSourceDirectory> 
     <outputDirectory>C:\Users\musaddique\workspace\XertoPublicApp\target\classes</outputDirectory> 
     <testOutputDirectory>C:\Users\musaddique\workspace\XertoPublicApp\target\test-classes</testOutputDirectory> 
     <resources> 
      <resource> 
       <directory>C:\Users\musaddique\workspace\XertoPublicApp\src</directory> 
       <excludes> 
        <exclude>**/*.java</exclude> 
       </excludes> 
      </resource> 
     </resources> 
     <testResources> 
      <testResource> 
       <directory>C:\Users\musaddique\workspace\XertoPublicApp\src\test\resources</directory> 
      </testResource> 
     </testResources> 
     <directory>C:\Users\musaddique\workspace\XertoPublicApp\target</directory> 
     <finalName>XertoPublicApp-0.0.1-SNAPSHOT</finalName> 

     <plugins> 
      <plugin> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>3.1</version> 
       <executions> 
        <execution> 
         <id>default-compile</id> 
         <phase>compile</phase> 
         <goals> 
          <goal>compile</goal> 
         </goals> 
         <configuration> 
          <source>1.7</source> 
          <target>1.7</target> 
         </configuration> 
        </execution> 
        <execution> 
         <id>default-testCompile</id> 
         <phase>test-compile</phase> 
         <goals> 
          <goal>testCompile</goal> 
         </goals> 
         <configuration> 
          <source>1.7</source> 
          <target>1.7</target> 
         </configuration> 
        </execution> 
       </executions> 
       <configuration> 
        <source>1.7</source> 
        <target>1.7</target> 
       </configuration> 
      </plugin>   
      <plugin> 
       <artifactId>maven-war-plugin</artifactId> 
       <version>2.4</version> 
       <executions> 
        <execution> 
         <id>default-war</id> 
         <phase>package</phase> 
         <goals> 
          <goal>war</goal> 
         </goals> 
         <configuration> 
          <warSourceDirectory>WebContent</warSourceDirectory> 
          <failOnMissingWebXml>false</failOnMissingWebXml> 
         </configuration> 
        </execution> 
       </executions> 
       <configuration> 
        <warSourceDirectory>WebContent</warSourceDirectory> 
        <failOnMissingWebXml>false</failOnMissingWebXml> 
       </configuration> 

     </plugins> 
    </build> 
    <reporting> 
     <outputDirectory>C:\Users\musaddique\workspace\XertoPublicApp\target\site</outputDirectory> 
    </reporting> 
</project> 
+2

在聚甲醛和項目結構把刪除Maven的戰爭插件將幫助其他人瞭解這個問題可能是 –

+0

還怎麼執行行家?如果你使用maven-war插件,它會引發一場戰爭。 –

+0

我想要jar文件,包含所有類 – Musaddique

回答

0

您正在使用Maven的戰爭插件,這導致戰爭輸出。 如果你可以刪除這個插件,你應該開始得到一個罐子。

0

刪除在pluginsmaven-war-plugin這是創建一個war文件,並descriptorRefjar-with-dependencies添加maven-assembly-plugin如果你需要所有的依賴類。

  <plugin> 
       <artifactId>maven-assembly-plugin</artifactId> 
       <version>2.6</version> 
       <configuration> 
        <descriptorRefs> 
         <descriptorRef>jar-with-dependencies</descriptorRef> 
        </descriptorRefs> 
       </configuration> 
      </plugin> 
相關問題