google-app-engine - 如何在 IntelliJ 12 中创建一个新的 Google App Engine 项目?

标签 google-app-engine intellij-idea

首先我要说我之前没有 GAE 经验——我试图让 GAE 在 IntelliJ 12 中工作但遇到了问题,想知道是否有人可以看看我在做什么并告诉我是否这里有任何奇怪的东西。

步骤:

  1. 使用 JDK 1.7.0_51 在 IntelliJ 中创建 Java 项目。点击下一步。

  2. 在所需的技术页面上选择 Web Application > Google App Engine 带有 appengine-java-sdk-1.8.9 的路径。单击“完成”。

  3. 将文件从 appengine-java-sdk-1.8.9/demos/new_project_template/ 复制到项目 目录

我现在的主目录结构如下:

.
├── 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>

“标识约束‘web-app-servlet-name-uniqueness’的字段匹配元素‘web-app’,但该元素没有简单类型”

最重要的是 - guestbook.GuestbookServlet 无法解析。

必须有一种更简单的方法让它在 Intellij 中运行 - 任何人都可以帮助我吗?

最佳答案

不幸的是,IntelliJ 并没有使这个过程变得简单。看起来他们希望您使用 Maven 来处理很多这样的事情。但这让尝试在 IntelliJ 上开始使用 GAE 的人变得更加困难。

您的项目现在一团糟。您已将 IntelliJ 为 Web 模块添加的内容与演示项目中的一些文件组合在一起。因此,首先,删除您的文件并从 IntelliJ 中删除您的 Web 模块。

现在回到您要使用的演示文件夹,它应该包括 COPYING、build.xml 以及 src 和 war 目录。将所有这些复制到您的项目中。然后进入项目结构->模块并导入模块。这将允许 IntelliJ 检测您的 Web 模块并避免创建重复的文件和目录。

您还需要在“设置”->“IDE 设置”->“应用程序服务器”下配置您的应用程序服务器。添加 Google App Engine 开发服务器并指定您的 SDK 目录。

然后返回到您的项目结构->模块->依赖项并添加一个库。选择您刚刚定义的应用程序服务器库。如果您的项目使用 GAE 的更高级功能,您将需要转到项目结构->工件并将库添加到您的工件。

同样对于 Artifact 的设置,您需要创建一个指向您的 war 目录的“爆炸 war ”定义。

可能需要更多配置...但我现在想不出来。让我知道您接下来遇到的问题,我可以尽力提供帮助。

关于google-app-engine - 如何在 IntelliJ 12 中创建一个新的 Google App Engine 项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21970666/

相关文章:

python - 想法运行/调试 py.test 单个测试而不是整个套件

Android Studio Cucumber for Java 插件

java - 如何在 IntelliJ 中快速输入记录器定义?

python - 在Python中,如何使用参数将用户转发到外部服务器?

python - Appengine REST 库 - Python 和 Django

python - SciPy 和 App Engine

google-app-engine - 如何在appengine dashboard的GQL Viewer中按键搜索?

google-app-engine - 清除 Google App Engine 中的日志

macos - 如何在 OS X 上运行 IntelliJ 和 Maven?

intellij-idea - Intellij : Before commit: run git hooks