0

我在运行我的第一个服务时遇到问题,因此决定从 lagom Maven archtype 项目中添加 hello-api 和 hello-impl 项目,看看它是否可以工作。它有,但我的没有。

背景

由于其他团队成员都是纯 Java 开发人员,我试图避免使用 sbt 和 activator。因此,目标是一切都在 Maven 中工作。

这是“mvn install”脚本输出的片段,用于显示构建的其他服务。

$ mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Archetype - mai-svcs
[INFO] mai-svc-common
[INFO] mai-actors-api               <======= WANT THE SERVICE FOR THIS ONE TO RUN
[INFO] mai-namespace-api
[INFO] mai-actors-impl
[INFO] mai-namespace-impl
[INFO] mai-i18n-phrases-api
[INFO] hello-api
[INFO] hello-impl
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Archetype - mai-svcs 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Archetype - mai-svcs ............................... SUCCESS [  2.774 s]
[INFO] mai-svc-common ..................................... SUCCESS [  7.190 s]
[INFO] mai-actors-api ..................................... SUCCESS [ 24.706 s]
[INFO] mai-namespace-api .................................. SUCCESS [ 12.628 s]
[INFO] mai-actors-impl .................................... SUCCESS [ 29.061 s]
[INFO] mai-namespace-impl ................................. SUCCESS [ 21.294 s]
[INFO] mai-i18n-phrases-api ............................... SUCCESS [ 22.091 s]
[INFO] hello-api .......................................... SUCCESS [  3.546 s]

注意:创建了一个类似于 HelloModule 类的 MAIActorsModule 类,并将 application.conf 文件添加到 src/main/resources 文件夹中。

发出命令“mvn lagom:runAll”时,最初,服务是记录的 hello 服务端口,但没有记录其他服务的端口。

$ mvn lagom:runAll
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Archetype - mai-svcs
[INFO] mai-svc-common
[INFO] mai-actors-api
[INFO] mai-namespace-api
[INFO] mai-actors-impl
[INFO] mai-namespace-impl
[INFO] mai-i18n-phrases-api
[INFO] hello-api
[INFO] hello-impl
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Archetype - mai-svcs 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- lagom-maven-plugin:1.2.1:runAll (default-cli) @ mai-svcs ---
[INFO] Starting Kafka
[INFO] Starting Cassandra
.[INFO] Did not find Netty's native epoll transport in the classpath, defaulting to NIO.
....[INFO] Using data-center name 'datacenter1' for DCAwareRoundRobinPolicy (if this is incorrect, please provide the correct datacenter name with DCAwareRoundRobinPolicy constructor)
[INFO] New Cassandra host /127.0.0.1:4000 added

[INFO] Cassandra server running at 127.0.0.1:4000
[INFO] Service locator is running at http://localhost:8000
[INFO] Service gateway is running at http://localhost:9000
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\lusp\mai_svcs\mai-svcs\hello-api\src\main\resources
[INFO] Nothing to compile - all classes are up to date
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
**[INFO] Nothing to compile - all classes are up to date
[INFO] Service hello-impl listening for HTTP on 0:0:0:0:0:0:0:0:57797
//           ----- NO ENTRY FOR mai-actors-impl!!!  -----
[INFO] (Service started, press enter to stop and go back to the console...)**

我错过了哪些步骤?

4

1 回答 1

0

您的每个<service>-impl项目都需要:

  1. 调用lagom-maven-plugin
  2. 用属性配置它<lagomService>true</lagomService>

pom.xml以下是您需要在每个服务实施项目中添加到文件中的示例片段:

<build>
    <plugins>
        <plugin>
            <groupId>com.lightbend.lagom</groupId>
            <artifactId>lagom-maven-plugin</artifactId>
            <configuration>
                <lagomService>true</lagomService>
            </configuration>
        </plugin>
    </plugins>
</build>

Lagom 文档在标题为定义 Lagom 构建的页面中有更多详细信息

于 2017-01-11T06:46:26.453 回答