Appengine multiple modules local dev - Java

2019-07-23 15:49发布

问题:

I have 3 java modules using Google Appengine Standard:

The first one module uses Java 7 with Servlet 2.5 + web.xml + Spring 4

The second module uses Java 8 with Servlet 3.1 without web.xml + Spring 5 using WebApplicationInitializer.

The third module is just to frontend files (HTML,CSS).

I have a dispatch.yaml that contains route for each module.


If I run only java8 module using:

mvn appengine:run OR /usr/lib/google-cloud-sdk/bin/java_dev_appserver.sh, 

It is ok, the modules run.

If I use: dev_appserver.py theJava8Module, happens the follow problem:

google.appengine.tools.devappserver2.errors.AppConfigNotFoundError: The "target/theJava8Module/WEB-INF" subdirectory exists but is missing web.xml

Before I had this java8 module, I used to run with this command:

dev_appserver.py --max_module_instances=1 frontendmodule/frontendmodule.yaml dispatch/dispatch.yaml java7Module/target/java7Module --dev_appserver_log_level=debug

When I use this command, it is ok, the 2 modules run and I can use the application and dispatch rules.


My question is, is there any way to run more than one module and using dispatch rules? Can I user dev_appserver.py (python) to run java8 application that does not have web.xml? Or Can I user mvn:appengine to run multiple modules and use dispatch.xml or dispatch.yaml?

Important: Could I run separete modules using mvn:appengine and dev_appserver, the problem is that the ports will be different, so the dispatch rules won't work.

Example:

dev_appserver.py --max_module_instances=1 frontendmodule/frontendmodule.yaml dispatch/dispatch.yaml java7Module/target/java7Module --dev_appserver_log_level=debug (port 8080)
mvn appengine:run java8module (port 9090)

回答1:

The User Guide for the appengine-maven-plugin covers running multiple modules. See if it helps.



回答2:

Regarding your module with Java7, you should know about the deprecation of Java7 runtime environment by Google Cloud.

Can I user dev_appserver.py (python) to run java8 application that does not have web.xml?

The Local Development Server for Java is documented here:

The App Engine SDK for Java includes a local development server for testing your application on your computer. The local development server simulates the App Engine Java runtime environment and all of its services, including Datastore.

The syntax description for the appengine-web.xml reference says that:

..... An App Engine Java app must have a file named appengine-web.xml in its WAR, in the directory WEB-INF/. This is an XML file whose root element is <appengine-web-app>. ....

Can I use mvn:appengine to run multiple modules and use dispatch.xml or dispatch.yaml?

According to this doc:

All dispatch files are ignored when running the local development server. The only way to target instances is through their ports.