如何将服务从应用程序 A 导入到应用程序 B?

How to import a service from application A into application B?

所以我有 2 个应用程序:A 和 B。应用程序 A 包含我创建的服务,我想在我的应用程序 B 中使用它。 有没有办法使用该服务而不是再次编写代码?

Is there a way to use that service instead of writing the code again?

是的。典型的做法是将共享代码放入库中,并从想要共享该代码的应用程序中使用该库。

顺便说一句...如果您正在使用 Gradle,https://plugins.gradle.org/plugin/io.micronaut.librarymicronaut-library 插件将会有所帮助。