目前我正在研究 Google App Engine 模块。我指的是the documentation
我对如何处理模型类或公共(public)类感到困惑。 以前我使用后端,因为所有代码都保存在项目中,但现在使用模块,我不知道如何管理公共(public)代码。
最佳答案
我创建了 Appstart ( https://github.com/omerio/appstart ) 一个基于样板 Maven 的多模块 App Engine 应用程序,它演示了 Guice、Jersey、Objectify、Cloud EndPoints 等技术的使用,并具有 3 个模块:前端模块、后端模块和通用模块模块包含所有公共(public)类(包括模型),它应该向您展示如何管理公共(public)代码的示例。该文件夹包含以下模块/maven项目
- 应用程序启动后端
- appstart-common
- appstart-ear
- 应用程序启动前端
后端模块仅包含后端所需的代码,前端包含前端代码,公共(public)模块包含公共(public)代码。这些项目设置在具有父级 Maven POM 的父文件夹“appstart”内。使用 Maven 依赖项将公共(public)模块包含在前端和后端中:
<!-- Common module dependency -->
<dependency>
<groupId>uk.co.inetria.appstart</groupId>
<artifactId>appstart-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
当您更改通用代码时,您可以运行 mvn clean,然后从 appstart-ear 目录进行安装,它应该会更新所有依赖的项目。我希望这有帮助
关于java - 如何在不同模块中处理App Engine模块Java中的公共(public)类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26259418/