我正在使用 java 创建 Google 应用程序引擎。 对于这个应用程序,我想预先填充数据库上的一些信息(例如:角色、权限等......) 如何在本地数据存储上执行此操作?当我上传应用程序时我该怎么做? 似乎有一些 python 工具可以与服务器数据存储一起使用,但不能与本地数据库一起使用。
最佳答案
将 Servlet 添加到您的应用程序,将您需要的数据保存到数据存储区。然后,只需在首次运行应用程序之前访问 servlet 的 URL。
这是最简单的方法。如果您想在将应用程序上传到 GAE 后使用此方法,请确保添加安全约束,以便只有您可以调用 servlet:
<security-constraint>
<web-resource-collection>
<url-pattern>/admin/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
https://developers.google.com/appengine/docs/java/config/webxml#Security_and_Authentication
关于java - 如何预填充 GAE 本地数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15531379/