java - 基于 Maven 配置文件的 web.xml 配置

标签 java maven google-app-engine web.xml

用什么maven插件可以得到appengine-web.xml基于maven配置文件运行生成的应用程序,例如-Pdev-Pprod

示例:

<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
  <application>myapp-dev</application>
  <version>1</version>
  <static-files/>
  <threadsafe>true</threadsafe>
  <precompilation-enabled>false</precompilation-enabled>
</appengine-web-app>

对于 -Pdev , 当配置文件是 -Pprod

应用程序名称将是:<application>myapp-prod</application>

最佳答案

您可以使用 maven-war-plugin 更改应用程序的版本和名称

在 appengine-web.xml 中,写下几行

<application>${appengine.app}</application>
<version>${version.number.gae}</version>

这是你需要的maven插件

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
        <warSourceDirectory>${project.basedir}/src/main/webapp</warSourceDirectory>
        <webappDirectory>${project.build.directory}/${project.artifactId}</webappDirectory>
        <filters>
            <filter>src/main/resources/application.properties</filter>
            <filter>src/main/webapp/WEB-INF/appengine-web.xml</filter>
        </filters>
        <webResources>
            <resource>
                <directory>src/main/webapp</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/appengine-web.xml</include>
                    <include>**/web.xml</include>
                    <include>open_graph/**</include>
                </includes>
            </resource>
        </webResources>

        <!-- Exclude all timestamp specific static files. (see maven-resource-plugin in this pom.xml) -->
        <warSourceExcludes>css/**,flash/**,mobile/**,images/**,<!--js/**,-->sounds/**,channel.html</warSourceExcludes>

    </configuration>
</plugin>

和 maven 配置文件

<profiles>
    <profile>
        <id>dev</id>
        <properties>
            <appengine.app>my-gae-dev</appengine.app>
            <version.number.gae>1</version.number.gae>
        </properties>
    </profile>
    <profile>
        <id>prod</id>
        <properties>
            <appengine.app>my-gae-prod</appengine.app>
            <version.number.gae>1</version.number.gae>
        </properties>
    </profile>
</profiles>

关于java - 基于 Maven 配置文件的 web.xml 配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29295297/

相关文章:

python - 在 Google Cloud Endpoints 中返回自定义 HTTP 错误原因

java - 如何将控制台输入传递给正在运行的 Java 程序而不是传递给 jdb?

java - GWT 异步回调上的 Hashmap 为空

java - 带有客户端证书身份验证的 HttpClient 后请求

java - 如何将 -h 参数传递给 maven 编译器插件以创建 JNI 头文件

google-app-engine - Appengine 上的 Map-Reduce 状态?

google-app-engine - GAE Cloud Endpoints API Explorer 停止工作

java - HTTP 状态 500 - 提交响应后无法转发

java - 即使没有注释,Junit 5也会在maven构建中执行测试

maven - 传递依赖不可见?