无法使用maven创建Web应用程序的jar文件

时间:2016-02-12 12:21:10

标签: java maven

我正在尝试创建Web应用程序的jar文件。但它只是创建war文件。我还更新了<packaging>jar</packaging>

但没有工作

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>

3 个答案:

答案 0 :(得分:0)

您正在使用maven-war-plugin,这会导致战争输出。 如果你可以删除这个插件,你应该开始得到一个罐子。

答案 1 :(得分:0)

删除正在创建maven-war-plugin文件的plugins中的war,如果您需要,请descriptorRef添加maven-assembly-plugin jar-with-dependencies <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.6</version> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </plugin> 依赖类。

webView = [[WKWebView alloc] initWithFrame:_displayView.frame];

答案 2 :(得分:-1)

从pom.xml中删除maven-war-plugin