Create Google App Engine Project in Eclipse with Modules

人走茶凉 提交于 2019-12-08 17:24:26

问题


I have been writing a GAE app with Eclipse with Maven as suggested on cloud.google.com. Recently, I needed to use "backends" or a different set of instances to handle a certain task. I found out that "backends" have been deprecated in favor of "modules". I have spent the last couple of days trying to set up the project to use modules and have made very little progress.

All I want to do is have different URLs dispatch to different sets of instances (using modules and dispatch.xml). Does anybody know how I convert my existing Eclipse project to do this? I am even willing to make a new project.

I need my modules to: 1) Use shared source code / classes from my original application 2) Have different numbers of resident instances 3) Honor the rules in dispatch.xml

I would like my project to run within eclipse and use either gradle or maven.


回答1:


I have same issue, i solved using this way.

Appstart (https://github.com/omerio/appstart) a boilerplate maven based multi-module App Engine application that demonstrates the use of technologies like Guice, Jersey, Objectify, Cloud EndPoints and has 3 modules a fronend module, backend module and common module which includes all the common classes including the model, which should show you an example of how to manage common code. The folder contains the following modules/maven projects

  • appstart-backend
  • appstart-common
  • appstart-ear
  • appstart-frontend

The backend module only contains code required for the backend, the frontend contains the frontend code and the common module contains common code. The projects are setup inside a parent folder 'appstart' with a parent maven POM. The common module is included in both the frontend and backend using a maven dependency:

<!-- Common module dependency -->
    <dependency>
        <groupId>uk.co.inetria.appstart</groupId>
        <artifactId>appstart-common</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>

When you change the common code you can run mvn clean then install from the appstart-ear directory and it should update all dependent projects. I hope this helps




回答2:


What I ended up doing was creating a new Enterprise Application Project in eclipse, copying my code and config into the new file structure, and then reimported the project as a maven project. Things seem ok for now.




回答3:


Here is a walkthrough of a multimodule project I created with eclipse Kepler.

1) create mymodule1 as a normal dynamic web project

Set target runtime : Google App Engine (x.x.x)

Set Add project to an ear: selected

Set EAR project name: myear

This will create two eclipse projects, one associated with the module and the other with the ear file:

mymodule1

myear

In the appengine-application.xml of both these projects set

<application></application>

to both hold the name of your GAE project (e.g. mygaeproject-11111) This name you should have already created in the cloud console, and will hold the multiple modules.

2) In the appengine-application.xml of mymodule1 under

<application>mygaeproject-11111</application>

add...

<module>mymodule1</module>

(Otherwise you end up with a "Multiple entries with same key" exception later)

3) In the appengine-application.xml of mymodule1, add the instance class you want the module to run on (inside appengine-web-app), for example:

<instance-class>F2</instance-class>

3) From the project menu clean both mymodule1 and myear. You can now deploy myear to your local google app server if you wish.

4) You will also need a default module to deploy to a production server, so Create mymodule2 as a normal dynamic web project

Set target runtime : Google App Engine (x.x.x)

Set Add project to an ear: selected

Set EAR project name: myear

5) In the appengine-application.xml of mymodule2 set the following, and set an instance class like before.

<application>mygaeproject-11111</application>
<module>default</module>

6) In the application.xml (Not appengine-application.xml) of myear set the context root associated with

<web-uri>mymodule2.war</web-uri> 

to

<context-root>default</context-root>

7) Ok now clean and build everything again and deploy to your local google app server. If all looks good simply rightclick on the server in the servers panel and select... Deploy to remote sever

8) If later you want to kill the project select it in your cloud console, then go to settings in the left pane and click disable application.



来源:https://stackoverflow.com/questions/27219020/create-google-app-engine-project-in-eclipse-with-modules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!