【问题标题】:file copy error with MavenMaven的文件复制错误
【发布时间】:2016-02-01 15:47:16
【问题描述】:

我想复制文件比较我的配置文件标识符。

我启动这个命令:

mvn -Pprod install

我有这个错误:

[ERROR] 未能执行目标 org.apache.maven.plugins:maven-resources-plugin:2.4:copy-resources (copy-web.xml) 在项目顶点:执行目标的 copy-web.xml org.apache.maven.plugins:maven-resources-plugin:2.4:copy-resources 失败:基本目录 D:\workspace\apex\src\main\webapp\WEB-INF\web.prod.xml 不是 目录 -> [帮助 1]

我的 pom.xml:

    <properties>
        <webXmlFile>web.xml</webXmlFile>
        <profileVersion>defaultVersion</profileVersion>
    </properties>

    <profiles>
        <profile>
            <id>dev</id>
            <properties>
                <profileVersion>DEV</profileVersion>
                <webXmlFile>web.dev.xml</webXmlFile>
            </properties>
        </profile>

        <profile>
            <id>preprod</id>
            <properties>
                <profileVersion>PREPROD</profileVersion>
                <webXmlFile>web.preprod.xml</webXmlFile>
            </properties>
        </profile>

        <profile>
            <id>prod</id>
            <properties>
                <profileVersion>PROD</profileVersion>
                <webXmlFile>web.prod.xml</webXmlFile>
            </properties>
        </profile>
    </profiles>

<build>
        <finalName>app-${project.version}</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.4</version>
                <executions>
                    <execution>
                        <id>copy-web.xml</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <overwrite>true</overwrite>
                            <outputDirectory>${basedir}/target/classes/WEB-INF</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>/src/main/webapp/WEB-INF/${webXmlFile}</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        ...
    ...
...

【问题讨论】:

  • “不是目录”消息对我来说很清楚:) 在您将文件作为目录传递的资源中,所以它在抱怨(不管它值得,我不是反对者)
  • @A.DiMatteo 是的,这对我来说很清楚,但是如何传递我的文件?

标签: java xml eclipse maven


【解决方案1】:

您需要对文件使用包含:

                            <resource>
                                <directory>/src/main/webapp/WEB-INF/</directory>
                               <includes>
                                <include> ${webXmlFile}</include>
                               </includes>
                            </resource>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-02
    • 2013-07-17
    • 1970-01-01
    • 2017-05-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多