How do I create a new Google App Engine project in

2019-05-06 22:43发布

I'll begin by saying that I have no prior GAE experience - I'm trying to get GAE working in IntelliJ 12 but having issues, was wondering if anyone could have a look over what I'm doing and tell me if there's anything wonky here.

Steps:

  1. Create Java project in IntelliJ with JDK 1.7.0_51. Click Next.

  2. Select Web Application > Google App Engine on desired techs page with path to appengine-java-sdk-1.8.9. Click Finish.

  3. Copy files from appengine-java-sdk-1.8.9/demos/new_project_template/ to project directory

I now have a main directory structure like:

.
├── COPYING
├── build.xml
├── html
│   └── index.html
├── src
│   ├── META-INF
│   │   └── jdoconfig.xml
│   ├── WEB-INF
│   │   ├── appengine-web.xml
│   │   └── web.xml
│   ├── log4j.properties
│   ├── logging.properties
│   └── org
│       └── example
│           └── HelloAppEngineServlet.java
├── test.iml
└── web
    ├── WEB-INF
    │   ├── appengine-web.xml
    │   └── web.xml
    └── index.jsp

Running this will run the webserver with the index.jsp in the web directory.

A few questions around this - should there be a 'web' and an 'html' directory? Why are there two WEB-INF directories and should they both be the same? Should I manually edit both of them each time I update one?

If I then follow the instructions at https://developers.google.com/appengine/docs/java/gettingstarted/creating it mentions a 'war' folder - I confess that I'm confused about the 'war', 'web' and 'html' folders - I think somewhere I've also seen referenced a 'www' folder. Do these folder names actually matter?

Following the tutorial I create a guestbook folder within the 'src' folder and make the java file. When I enter the info in the web.xml (both of them) I get an error for the line

<servlet-name>guestbook</servlet-name>

"A field of identity constraint 'web-app-servlet-name-uniqueness' matched element 'web-app', but this element does not have a simple type"

To top that off - guestbook.GuestbookServlet doesn't resolve.

There has to be a simpler way of getting this running in Intellij - can anyone help me?

2条回答
smile是对你的礼貌
2楼-- · 2019-05-06 22:53

Unfortunately, IntelliJ does not make this process simple. It seems like they expect you to use Maven to handle a lot of this. But this makes things a lot harder on people trying to get started with GAE on IntelliJ.

Your project is a mess right now. You have combined things that IntelliJ added for your web module with some of the files from the demo projects. So to start, remove your files and remove your web module from IntelliJ.

Now go back to the demo folder that you want to use, it should include the COPYING, build.xml, and a src and war dir. Copy all of those to your project. Then go into project structure->modules and import module. This will allow IntelliJ to detect your web module and avoid creating duplicate files and dirs.

You also need to configure your Application Server under Settings->IDE Settings->Application Servers. Add a Google App Engine Dev Server and specify your SDK directory.

Then go back to your Project Structure->Module->Dependencies and add a Library. Select the Application Server Library that you just defined. If your project uses more advanced features of GAE, you will need to go to Project Structure->Artifacts and add the libraries to your artifact.

Also for the settings on the Artifact, you need to create an 'exploded war' definition that points to your war dir.

There is likely more configuration needed... but I can't think of it all right now. Let me know what you get stuck on next and I can try to help.

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-05-06 23:06

IntelliJ IDEA 14 Ultimate has integrated GAE support. How comprehensive this is I'm not totally sure yet. I'll update this answer shortly with more details.

https://www.jetbrains.com/idea/features/google_app_engine.html

查看更多
登录 后发表回答