【问题标题】:Declaring Extra Resource for the Apache Tomcat Maven plugin exec-war-only goal?为 Apache Tomcat Maven 插件 exec-war-only 目标声明额外资源?
【发布时间】:2015-09-30 20:41:56
【问题描述】:

我正在尝试为我的构建配置 exec-war-only 目标以包含一些额外资源(一些配置文件)。我正在使用的配置如下所示

 <plugin>
     <groupId>org.apache.tomcat.maven</groupId>
     <artifactId>tomcat7-maven-plugin</artifactId>
     <version>2.2</version>
     <executions>
         <execution>
             <phase>package</phase>
             <goals>
                 <goal>exec-war-only</goal>
             </goals>
         </execution>
     </executions>
     <configuration>
         <buildDirectory>${project.basedir}/../kmszip/</buildDirectory>
         <path>/kms</path>
         <finalName>${project.artifactId}.jar</finalName>
         <enableNaming>true</enableNaming>
         <extraResources>
             <directory>${project.basedir}/</directory>
             <includes>
                 <include>config.json</include>
             </includes>
         </extraResources>
     </configuration>
 </plugin>

使用上述配置构建时出现以下错误

[错误] 无法在项目 KeyManagementService 上执行目标 org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:exec-war-only(默认):无法解析 mojo org.apache.tomcat 的配置。 maven:tomcat7-maven-plugin:2.2:exec-war-only 用于参数目录:在类 org.apache.tomcat.maven.plugin.tomcat7.run.ExtraResource 中找不到默认设置器 -> [帮助 1]

我还尝试对&lt;extraResources&gt; 使用以下配置,并得到与上述类似的错误。

<extraResources>
    <extraResource>${project.basedir}/config.json</extraResource>
</extraResources>

【问题讨论】:

    标签: java maven tomcat tomcat7-maven-plugin


    【解决方案1】:

    您在&lt;extraResources&gt; 下缺少&lt;extraResource&gt; 标签。正确的配置应该是:

    <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.2</version>
        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                    <goal>exec-war-only</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <buildDirectory>${project.basedir}/../kmszip/</buildDirectory>
            <path>/kms</path>
            <finalName>${project.artifactId}.jar</finalName>
            <enableNaming>true</enableNaming>
            <extraResources>
                <extraResource>
                    <directory>${project.basedir}/</directory>
                    <includes>
                        <include>config.json</include>
                    </includes>
                </extraResource>
            </extraResources>
        </configuration>
    </plugin>
    

    【讨论】:

      猜你喜欢
      • 2014-02-23
      • 1970-01-01
      • 2013-08-02
      • 1970-01-01
      • 2015-03-13
      • 1970-01-01
      • 2016-02-14
      • 1970-01-01
      • 2011-02-28
      相关资源
      最近更新 更多