如何在IntelliJ 12中创建新的Google App Engine项目? [英] How do I create a new Google App Engine project in IntelliJ 12 which works?

查看:353
本文介绍了如何在IntelliJ 12中创建新的Google App Engine项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我首先说我没有GAE的经验 - 我试图让GAE在IntelliJ 12中工作,但有问题,想知道是否有人可以看看我在做什么,并告诉我是否

步骤:


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

  2. Google App Engine 在所需的技术页面
    上,路径为 appengine-java-sdk-1.8.9 。点击Finish。


  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

运行这个命令将运行带有索引的web服务器。 jsp在web目录下。

围绕这个问题的几个问题 - 应该有'网页'和'html'目录吗?为什么有两个WEB-INF目录,它们应该是相同的?我应该每次手动更新它们两次吗? 如果我按照 https://developers.google.com/appengine/docs/java/gettingstarted/creating 它提到了一个'war'文件夹 - 我承认我对'战争','网页'和'html'文件夹感到困惑 - 我想我也曾经在某个地方引用了'www'文件夹。这些文件夹名称是否真的很重要?



在教程之后,我在'src'文件夹中创建一个留言文件夹并创建java文件。当我在web.xml中输入信息时(两者都有),我得到一行错误信息:

 < servlet-名称>&留言本LT; / servlet的名称> 

身份约束字段'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目录。然后返回到您的项目结构 - >模块 - >依赖关系并添加一个库。

选择您刚才定义的Application Server Library。如果您的项目使用GAE的更多高级功能,则需要转至Project Structure-> Artifacts并将库添加到您的工件中。



另外,神器,你需要创建一个'爆炸战争'的定义,指向你的战争目标。



有可能需要更多的配置...但我想不出现在好了。让我知道你接下来会发生什么,我可以尝试提供帮助。

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?

解决方案

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.

这篇关于如何在IntelliJ 12中创建新的Google App Engine项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆