首页 文章

如何让'mvn lagom:runAll'让我的服务在端口上监听?

提问于
浏览
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类,并在src / main / resources文件夹中添加了application.conf文件 .

当发出命令'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...)**

我错过了哪些步骤?

1 回答

  • 0

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

    • 调用 lagom-maven-plugin

    • 使用属性 <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文档在 Headers 为Defining a Lagom build的页面中有更多详细信息

相关问题