Java Eclipse 上的野蝇群

Java wildfly swarm on Eclipse

美好的一天 Java 和 Wildfly Swarm 大师,

我有一个问题。 我使用 Wildfly Swarm 和 EJB 在 Eclipse 中构建了一个微服务项目。 该项目名为 TestProject,将构建一个 TestProject.war.

当我 运行 在终端中使用命令 "mvn wildfly-swarm:run" 时,它会 运行 正确地生成正确的 war 文件。以下是 运行s:

时的片段
2017-09-12 12:03:34,884 INFO  [org.xnio.nio] (MSC service thread 1-7) XNIO NIO Implementation Version 3.4.0.Final
2017-09-12 12:03:34,971 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-7) WFLYUT0012: Started server default-server.
2017-09-12 12:03:35,056 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0006: Undertow HTTP listener default listening on [0:0:0:0:0:0:0:0]:8080
2017-09-12 12:03:35,176 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Swarm 2017.3.3 (WildFly Core 2.2.1.CR1) started in 1140ms - Started 132 of 143 services (25 services are lazy, passive or on-demand)
2017-09-12 12:03:36,380 INFO  [org.wildfly.swarm.runtime.deployer] (main) deploying TestProject.war
2017-09-12 12:03:36,398 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) WFLYSRV0027: Starting deployment of "TestProject.war" (runtime-name: "TestProject.war")
2017-09-12 12:03:37,779 WARN  [org.jboss.as.dependency.private] (MSC service thread 1-2) WFLYSRV0018: Deployment "deployment.TestProject.war" is using a private module ("org.jboss.jts:main") which may be changed or removed in future versions without notice.
2017-09-12 12:03:38,114 INFO  [org.jboss.as.ejb3.deployment] (MSC service thread 1-1) WFLYEJB0473: JNDI bindings for session bean named 'ProductRestBean' in deployment unit 'deployment "TestProject.war"' are as follows:

    java:global/TestProject/ProductRestBean!com.mycompany.ejb.ProductRestBeanInterface
    java:app/TestProject/ProductRestBean!com.mycompany.ejb.ProductRestBeanInterface
    java:module/ProductRestBean!com.mycompany.ejb.ProductRestBeanInterface
    java:global/TestProject/ProductRestBean
    java:app/TestProject/ProductRestBean
    java:module/ProductRestBean

当我 运行 在 Eclipse IDE 中时,它仍然会 运行,但是它创建的 war 是不同的并且导致 bean 加载并稍后查找, 无法加载。 下面是关于它如何在 Eclipse 中 运行s(有问题)的片段:

[0m[0m2017-09-12 12:36:46,741 INFO  [org.xnio.nio] (MSC service thread 1-6) XNIO NIO Implementation Version 3.4.0.Final
[0m[0m2017-09-12 12:36:46,795 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-6) WFLYUT0012: Started server default-server.
[0m[0m2017-09-12 12:36:46,871 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-7) WFLYUT0006: Undertow HTTP listener default listening on [0:0:0:0:0:0:0:0]:8080
[0m[0m2017-09-12 12:36:46,997 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Swarm 2017.3.3 (WildFly Core 2.2.1.CR1) started in 1197ms - Started 132 of 143 services (25 services are lazy, passive or on-demand)
[0m[0m2017-09-12 12:36:48,232 INFO  [org.wildfly.swarm.runtime.deployer] (main) deploying 507ac020-cc98-4956-9c88-418869842dcf.war
[0m[0m2017-09-12 12:36:48,252 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) WFLYSRV0027: Starting deployment of "507ac020-cc98-4956-9c88-418869842dcf.war" (runtime-name: "507ac020-cc98-4956-9c88-418869842dcf.war")
[0m[33m2017-09-12 12:36:49,676 WARN  [org.jboss.as.dependency.private] (MSC service thread 1-8) WFLYSRV0018: Deployment "deployment.507ac020-cc98-4956-9c88-418869842dcf.war" is using a private module ("org.jboss.jts:main") which may be changed or removed in future versions without notice.
[0m[0m2017-09-12 12:36:49,966 INFO  [org.jboss.as.ejb3.deployment] (MSC service thread 1-3) WFLYEJB0473: JNDI bindings for session bean named 'ProductRestBean' in deployment unit 'deployment "507ac020-cc98-4956-9c88-418869842dcf.war"' are as follows:

    java:global/507ac020-cc98-4956-9c88-418869842dcf/ProductRestBean!com.mycompany.ejb.ProductRestBeanInterface
    java:app/507ac020-cc98-4956-9c88-418869842dcf/ProductRestBean!com.mycompany.ejb.ProductRestBeanInterface
    java:module/ProductRestBean!com.mycompany.ejb.ProductRestBeanInterface
    java:global/507ac020-cc98-4956-9c88-418869842dcf/ProductRestBean
    java:app/507ac020-cc98-4956-9c88-418869842dcf/ProductRestBean
    java:module/ProductRestBean

我们可以观察到,它创建了 war 文件:

507ac020-cc98-4956-9c88-418869842dcf.war

而不是:

TestProject.war

我很高兴能就如何防止 Eclipse 创建随机命名的 war 文件并使用预期的 war 文件名 TestProject.war 提供一些见解。

非常感谢! 祝你有美好的一天 =)!

解决方案是将这些行添加到项目的 projects-default.yml 中。

swarm:
  app:
    name: TestProject.war