Intellij IDEA工件'XXXX:war explosion'具有无效扩展名 [英] Intellij IDEA artifact 'XXXX:war exploded' has invalid extension

查看:285
本文介绍了Intellij IDEA工件'XXXX:war explosion'具有无效扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次我对POM进行最细微的更改时,Intellij会在Project Structure输出目录设置中删除爆炸工件的.war扩展名。这会导致Intellij的运行/调试配置出错:

Every time I make even the tiniest change to my POM Intellij removes the .war extension for my exploded artifact in the Project Structure output directory setting. This causes an error in Intellij's Run/Debug configuration:

神器'XXXX:war explosion'的扩展名无效。

为了解决这个问题,我必须手动覆盖Project Structure输出目录设置。每次我对POM进行最微小的更改时,我必须返回到Output目录设置并手动将.war附加到Output目录设置的末尾。这变得非常古老而令人沮丧。

In order to resolve the issue I must manually override the Project Structure output directory setting. Every time I make even the tiniest change to the POM I must go back to the Output directory setting and manually append ".war" to the end of the Output directory setting. This is getting very old and frustrating.

例如。我必须改变这个:

e.g. I must change this:

E:\ workarea\enterp\application\target\application

E:\workarea\enterp\application\target\application

到此:

E:\ workarea\enterp\application\target\application.war

E:\workarea\enterp\application\target\application.war

如果我按如下方式手动设置Maven WAR插件outputDirectory配置,这根本没有帮助:

If I manually set the Maven WAR plugin outputDirectory configuration as follows, this does not help at all:

<plugin>
    <artifactId>maven-war-plugin</artifactId>
    <version>${maven.war.plugin.version}</version>
    <configuration>

        <!-- Output directory of artifact:war exploded keeps losing the .war extension -->
        <outputDirectory>${project.build.directory}.war</outputDirectory>

    </configuration>
</plugin>

如何解决此问题?

编辑:

这是完整的构建配置:

    <build>
    <!-- Maven will append the version to the finalName (which is the name
        given to the generated war, and hence the context root) -->
    <finalName>${project.artifactId}</finalName>

    <plugins>
        <!-- Compiler plugin enforces Java 1.6 compatibility and activates annotation
            processors -->
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven.compiler.plugin.version}</version>
            <configuration>
                <source>${maven.compiler.source}</source>
                <target>${maven.compiler.target}</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>${maven.war.plugin.version}</version>
            <configuration>
                <!-- Output directory of artifact:war exploded keeps losing the .war extension -->
                <outputDirectory>${project.build.directory}/${project.artifactId}.war</outputDirectory>

                <!-- Java EE 7 doesn't require web.xml, Maven needs to catch up! -->
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
        <!-- The WildFly plugin deploys your war to a local WildFly container -->
        <!-- To use, run: mvn package wildfly:deploy -->
        <plugin>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-maven-plugin</artifactId>
            <version>${version.wildfly.maven.plugin}</version>
        </plugin>
    </plugins>

</build>

第二次编辑:

我发现一个解决方案是在构建配置中将.war附加到$ {project.artifactId},例如:

I discovered that one solution is to append ".war" to ${project.artifactId} in the build configuration, e.g.:

<finalName>${project.artifactId}.war</finalName>

并从插件配置中删除outputDirectory。因此构建配置应如下所示:

and remove outputDirectory from the plugin configuration. So the build config should look like this:

<build>
    <!--
        Maven will make finalName the name of the generated war.

        NOTE:   Output directory of artifact:war exploded keeps losing the .war extension
                http://youtrack.jetbrains.com/issue/IDEA-86484
                http://youtrack.jetbrains.com/issue/IDEA-95162

                The solution is to append ".war" to ${project.artifactId}, below:
    -->
    <finalName>${project.artifactId}.war</finalName>

    <plugins>
        <!-- Compiler plugin enforces Java 1.6 compatibility and activates annotation
            processors -->
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven.compiler.plugin.version}</version>
            <configuration>
                <source>${maven.compiler.source}</source>
                <target>${maven.compiler.target}</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>${maven.war.plugin.version}</version>
            <configuration>
                <!-- Java EE 7 doesn't require web.xml, Maven needs to catch up! -->
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
        <!-- The WildFly plugin deploys your war to a local WildFly container -->
        <!-- To use, run: mvn package wildfly:deploy -->
        <plugin>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-maven-plugin</artifactId>
            <version>${version.wildfly.maven.plugin}</version>
        </plugin>
    </plugins>

</build>

免责声明:如果您使用此解决方法,请注意当您部署未爆炸的WAR工件时文件名将命名为XXXX.war.war。它工作 - 我将工件部署为Intellij中的WAR文件 - 但它很难看。

DISCLAIMER: If you use this workaround just be aware that when you deploy an unexploded WAR artifact the file name will be named XXXX.war.war. It works -- I deployed the artifact as a WAR file in Intellij -- but it's ugly.


INFO [org.jboss.as。 server.deployment](MSC服务线程1-7)JBAS015876:开始部署XXXX.war.war(运行时名称:XXXX.war.war)

INFO [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015876: Starting deployment of "XXXX.war.war" (runtime-name: "XXXX.war.war)"

如果有人可以告诉我如何配置Intellij项目以使用Maven来选择一个或另一个finalName值,具体取决于我是部署WAR文件还是爆炸工件,那么这个问题将得到充分的回答。

If someone can tell me how to configure the Intellij project to work with Maven to select one or the other finalName values depending on whether I'm deploying a WAR file vs. exploded artifact then this question will be sufficiently answered.

<!-- Exploded artifact --> 
<finalName>${project.artifactId}.war</finalName>

<!-- WAR file (unexploded) artifact --> 
<finalName>${project.artifactId}</finalName>


推荐答案

有一种方法可以在IntelliJ中修复此问题,而无需更改你的pom.xml文件,通过添加一个引用爆炸战争(或者在我的情况下,爆炸的耳朵)的工件,并且每次IntelliJ重新导入maven pom时它都不会被踩踏。方法如下:

There's a way to fix this in IntelliJ, without changing your pom.xml file(s), by adding an artifact with a reference to the exploded war (or in my case, the exploded ear) and it won't get stomped every time IntelliJ re-imports the maven pom(s). Here's how:


  1. 停止/取消部署当前的工件部署

  1. Stop/undeploy your current artifact deployment

编辑运行配置,在部署选项卡中,删除当前爆炸的战争/耳朵工件

Edit your run config, and in the Deployment tab, remove the current exploded war/ear artifact

打开项目的工件设置并添加新工件

Open the project's Artifacts settings and add a new artifact

使用加号按钮添加新的战争或(在我的情况下)耳朵爆炸神器

Use the plus button to add a new war or (in my case) ear exploded artifact

给它起一个名字,然后编辑输出目录以添加相应的扩展名(.war或.ear)

Give it a name, then edit the Output directory to add the appropriate extension (.war or .ear)

在输出布局部分中,您可以看到< output root> ,使用加号按钮添加工件

In the Output Layout section where you see <output root>, use the plus button to add an Artifact

选择所需的爆炸工件

Select the desired exploded artifact

再次编辑运行配置,并在部署选项卡中添加新的解决方法爆炸工件

Edit your run config again, and in the Deployment tab, add the new workaround exploded artifact

感谢Nikolay Chashnikov在他对错误的评论中对此进行了描述报告

Thanks to Nikolay Chashnikov for describing this in his comment on the bug report

这篇关于Intellij IDEA工件'XXXX:war explosion'具有无效扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆