简体   繁体   English

Maven War:部署描述符的文件名

[英]Maven War: Filename of deployment descriptor

So I've added the maven-war-plugin to my pom.xml and added: 所以我已经将maven-war-plugin添加到我的pom.xml中并添加了:

<configuration>
    <webXml>WEB-INF/glassfish-web.xml</webXml>
</configuration>

Now when I package my app this descriptor gets renamed to web.xml which causes a failure when trying to deploy my application to my glassfish server, since the server thinks the web.xml is malformatted I guess. 现在当我打包我的应用程序时,这个描述符被重命名为web.xml,这在尝试将我的应用程序部署到我的glassfish服务器时导致失败,因为服务器认为web.xml是错误格式化的。 So how can I tell maven to leave the file name untouched? 那么如何告诉maven保持文件名不受影响?

<webXml> configuration isn't mandatory for maven-war-plugin . <webXml>配置对于maven-war-plugin不是必需的。 So, If you don't explicitly mention the webXml, It won't rename the file. 因此,如果您没有明确提及webXml,它将不会重命名该文件。 You will get the expected behaviour if you remove this webXml entry from your pom.xml 如果从pom.xml删除此webXml条目,您将获得预期的行为

Edit 1 编辑1

I don't think there is an option to skip webXml file renaming. 我认为没有选项可以跳过webXml文件重命名。 You can try copy-resources task in maven-resources plugin . 您可以在maven-resources plugin尝试copy-resources任务。 You can configure a resource file/directory mappings from Project dir to War archive. 您可以配置从Project dir到War archive的资源文件/目录映射。

    <plugins>
        <-- other plugin configurations.... -->
        <plugin>
            <artifactId>maven-resources-plugin</artifactId>
              <version>3.1.0</version>
                <executions>
                  <execution>
                    <id>copy-resources</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>
                        ${basedir}/target/app/WEB-INF
                        </outputDirectory>
                        <resources>
                          <resource>
                            <directory>WEB-INF</directory>
                            <includes>glassfish-web.xml</includes>
                        </resource>
                        <resource>
                            <directory>{another directory from where all files are copied}
                            </directory>
                        </resource>
                        <resource>
                           <directory>
                           {another directory from where, all but test.properties are copied}
                           </directory>
                           <excludes>test.properties</excludes>
                        </resource>
                    </resources>
                </configuration>
            </execution>
        </executions>
    </plugin>
  <plugins/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM