使用maven将web应用程序中的jar文件复制到webapp / WEB-INF / lib中,以便在WEB-INF / lib下进行战争

时间:2017-09-15 10:43:10

标签: maven maven-plugin

我在webapp / WEB-INF / lib /文件夹下添加了一个依赖项。

当我使用maven构建时,我想在战争中将其复制到WEB-INF / lib而不是WEB-INF / classes / WEB-INF / lib。我正在寻找使用maven本身完成的事情。

我在pom文件中提到打包为war。仍然没有复制依赖项。我错过了pom文件中的内容。 我复制了下面的pom:

<?xml version="1.0" encoding="UTF-8"?>
<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>****</groupId>
    <artifactId>*****</artifactId>
    <name>****</name>
    <description>*****</description>
    <parent>
        <groupId>****</groupId>
        <artifactId>***</artifactId>
        <version>17.6</version>
    </parent>
    <properties>
        <jbpm.version>6.3.0.Final</jbpm.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.jbpm</groupId>
            <artifactId>jbpm-test</artifactId>
            <version>${jbpm.version}</version>
        </dependency>
        <dependency>
            <groupId>Assets.CKAF.Bundles</groupId>
            <artifactId>csf-kafka</artifactId>
            <version>1.2-0.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka_2.10</artifactId>
            <version>0.10.0.0</version>
        </dependency>
        <dependency>
            <groupId>dom4j</groupId>
            <artifactId>dom4j</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>com.opencsv</groupId>
            <artifactId>opencsv</artifactId>
            <version>4.0</version>
        </dependency>
        <dependency>
            <groupId>de.ruedigermoeller</groupId>
            <artifactId>fst</artifactId>
            <version>2.47</version>
        </dependency>
        <dependency>
            <groupId>org.apache.avro</groupId>
            <artifactId>avro</artifactId>
            <version>1.8.1</version>
        </dependency>
        <dependency>
            <groupId>io.confluent</groupId>
            <artifactId>kafka-avro-serializer</artifactId>
            <version>3.0.0</version>
        </dependency>
        <dependency>
            <groupId>io.confluent</groupId>
            <artifactId>common-config</artifactId>
            <version>3.0.0</version>
        </dependency>
        <dependency>
            <groupId>io.confluent</groupId>
            <artifactId>kafka-schema-registry-client</artifactId>
            <version>3.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.8.7</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.module</groupId>
            <artifactId>jackson-module-jaxb-annotations</artifactId>
            <version>2.8.5</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>jaxrs-api</artifactId>
            <version>3.0.7.Final</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-core</artifactId>
            <version>2.19.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-spring</artifactId>
            <version>2.19.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache-extras.camel-extra</groupId>
            <artifactId>camel-jboss6</artifactId>
            <version>2.18.0</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-core</artifactId>
            <version>2.2.11</version>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.2.11</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.2.11</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-rt</artifactId>
            <version>2.2.10</version>
        </dependency>
    </dependencies>
    <packaging>war</packaging>
</project>

附上战争内容的截图。

war home folder WEB-INF content

1 个答案:

答案 0 :(得分:1)

你的POM似乎很好。并且由于您没有为依赖项指定任何“范围”,因此应用“compile”的默认范围,这意味着一旦执行“mvn clean install”,它应该将所有这些依赖项打包到“lib”文件夹中你的战争文件。

我看到的另一件事是你在这个POM中有一个父节,如果你在父项目中有这些依赖项,如果它们的范围是“提供”,那么你不会在war文件的lib文件夹下看到它们。