首页 文章

部署目录中的war文件名错误

提问于
浏览
4

我在Eclipse中访问:http://localhost:8080/bword时收到"404 Not found"错误消息 .

此应用程序在Wildfly中提供 . 在POM.xml中,它定义:

<artifactId>bword</artifactId>
<packaging>war</packaging>
<name>bword</name>

但是,奇怪的是,当我在Eclipse中运行应用程序并将Wildfly 9.0配置为服务器时,部署到wildfly / standone / deployments /中的是bbword.war,如下所示:

[abigail@localhost wildfly-9.0.2.Final]$ ls standalone/deployments/
bbword.war/          bbword.war.deployed

哪个错了,应该是“bword.war /”和“bword.war.deployed” .

在Eclipse之外,如果我在项目“bword”下“mvn clean package”,我可以在target /目录下获得“bword.war” .

请参阅附件屏幕截图以供参考 . 我怀疑在我的pom,或eclipse,或任何地方的某处,有一个“bbword”的错误配置,而不是“bword”,但我无法真正找到它 . 我找不到任何“bbword”的痕迹 . 什么决定了部署下部署的war文件的名称?

见附件 .

enter image description here

编辑(POM.xml的一部分):

<build>
            <!-- Set the name of the war, used as the context root when the app 
                is deployed -->
            <finalName>${project.artifactId}</finalName>
            <plugins>
                <plugin>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>${version.war.plugin}</version>
                    <configuration>
                        <!-- Java EE 7 doesn't require web.xml, Maven needs to catch up! -->
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>
                <!-- WildFly plugin to deploy war -->
                <plugin>
                    <groupId>org.wildfly.plugins</groupId>
                    <artifactId>wildfly-maven-plugin</artifactId>
                    <version>${version.wildfly.maven.plugin}</version>
                </plugin>
                <!-- Compiler plugin enforces Java 1.6 compatibility and activates 
                    annotation processors -->
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${version.compiler.plugin}</version>
                    <configuration>
                        <source>${maven.compiler.source}</source>
                        <target>${maven.compiler.target}</target>
                    </configuration>
                </plugin>
            </plugins>
        </build>

还有一个补充:

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
17:32:35,508 INFO  [org.jboss.modules] (main) JBoss Modules version 1.4.3.Final
17:32:35,702 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final
17:32:35,761 INFO  [org.jboss.as] (MSC service thread 1-6) WFLYSRV0049: WildFly Full 9.0.2.Final (WildFly Core 1.0.2.Final) starting
17:32:36,573 INFO  [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 22) WFLYCTL0028: Attribute 'job-repository-type' in the resource at address '/subsystem=batch' is deprecated, and may be removed in future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
17:32:36,594 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0004: Found bbword.war in deployment directory. To trigger deployment create a file called bbword.war.dodeploy
17:32:36,625 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
17:32:36,647 INFO  [org.xnio] (MSC service thread 1-5) XNIO version 3.3.1.Final

......

在我单击Wildfly上的“作为服务器运行”后,这是控制台消息的最初部分 . 它似乎显示“在部署目录中找到bbword.war” . 在运行它之前,我删除了所有独立/部署/ * . 它以空目录开头 . 每当我运行服务器时,似乎都会将“bbword.war”复制到此目录中 . 我想不出来 . 我在计算机上使用“find / -name bbword.war”但找不到此文件 . 真的很困惑 .

更新:

最终发现了问题:在项目'bword'下,有一个“.setting”目录,其中包含以下文件:bword / .settings / org.eclipse.wst.common.component

其中有一行:“bbword”是我之前使用的部署名称 . 删除此目录并在Maven中运行“update”似乎解决了这个问题 . 特别是,我需要同时执行这两个操作,首先删除此设置,.setting,然后更新maven .

有几天浪费了这个,但很高兴知道这一点 .

2 回答

  • 1

    首先,尝试在服务器上部署maven构建的工件(bword.war)(不要忘记首先完全清理任何Eclipse部署的工件) .
    只需将 bword.war/target 文件夹移动到 path_to_wildfly/standalone/deployments 文件夹即可完成此操作 .
    检查服务器日志文件以查找部署战争后应显示的消息: Registered web context: <web_context_name> . 如果它表示/ bbword - 这不是您所期望的,请检查 src/main/webapp/WEB-INF 中是否有 jboss-web.xml 文件,将其指定为 web-context 值 .

    如果maven工件导致正确的webcontext - / bword,则它必须是Eclipse配置问题 . 您是否尝试过从Maven更新Eclipse项目? :

    • 右键单击您的项目

    • 选择Maven

    • 选择更新项目

    • 从Wildfly服务器中删除您的项目,然后重新添加 . 如果这没有帮助,请尝试添加新的服务器运行时并在那里添加项目 . 最后的办法是创建一个新的Eclipse工作区 .

    祝好运 .

  • 1

    有同样的问题并通过更正这两个文件来修复它:

    .settings / org.eclipse.wst.common.component => deploy-name等

    .project =>名字

相关问题