为 Apache Tomcat Maven 插件 exec-war-only 目标声明额外资源?
Declaring Extra Resource for the Apache Tomcat Maven plugin exec-war-only goal?
我正在尝试为我的构建配置 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>
使用上述配置构建时出现以下错误
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:exec-war-only (default) on project KeyManagementService: Unable to parse configuration of mojo org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:exec-war-only for parameter directory: Cannot find default setter in class org.apache.tomcat.maven.plugin.tomcat7.run.ExtraResource -> [Help 1]
我也尝试使用下面的配置 <extraResources>
并得到了与上面类似的错误。
<extraResources>
<extraResource>${project.basedir}/config.json</extraResource>
</extraResources>
您缺少 <extraResources>
下的 <extraResource>
标签。正确的配置应该是:
<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>
我正在尝试为我的构建配置 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>
使用上述配置构建时出现以下错误
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:exec-war-only (default) on project KeyManagementService: Unable to parse configuration of mojo org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:exec-war-only for parameter directory: Cannot find default setter in class org.apache.tomcat.maven.plugin.tomcat7.run.ExtraResource -> [Help 1]
我也尝试使用下面的配置 <extraResources>
并得到了与上面类似的错误。
<extraResources>
<extraResource>${project.basedir}/config.json</extraResource>
</extraResources>
您缺少 <extraResources>
下的 <extraResource>
标签。正确的配置应该是:
<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>