简体   繁体   English

如何在IntelliJ IDEA中启动新的vaadin项目?

[英]How do I start a new vaadin project in IntelliJ IDEA?

The answer based on the maven archetype approach works. 基于maven原型方法的答案有效。 I will update and accept an answer based on using the built in wizard if the IntelliJ wizard/template for Vaadin is ever fixed.* 如果Vaadin的IntelliJ向导/模板被修复,我将基于使用内置向导更新并接受答案。*

I managed to create a new project using the maven archetype from a terminal window, and then import that into IntelliJ IDEA, configured the GWT facet, but now when I run it says: 我设法使用终端窗口中的maven原型创建一个新项目,然后将其导入IntelliJ IDEA,配置GWT方面,但现在我运行时说:

"Error running unnamed: No GWT Modules found in 'projectname'"

I confess to being a total beginner at Java, IntellIJ, and Vaadin, not to mention GWT. 我承认自己是Java,IntellIJ和Vaadin的初学者,更不用说GWT了。

I also tried creating a new Vaadin projet using the native Vaadin plugin that comes with IntelliJ IDEA (Ultimate). 我还尝试使用IntelliJ IDEA(Ultimate)附带的原生Vaadin插件创建一个新的Vaadin项目。 I am using Ultimate, but it's a trial. 我正在使用Ultimate,但这是一个试验。

在此输入图像描述

Update:: Originally I could not see any Vaadin projects in the New Project window's list of available project templates. 更新::最初我在“新建项目”窗口的可用项目模板列表中看不到任何Vaadin项目。 That's because I was confused by the two-levels-of-new-projects idea in IntelliJ's new project wizard. 那是因为我对IntelliJ的新项目向导中的两个级别的新项目想法感到困惑。 Sorted that out now. 现在排序了。

Update2:: I can follow the steps from EITHER of the two answers below and get a project that builds but it doesn't run. Update2 ::我可以按照下面两个答案的EITHER中的步骤获得一个构建但不运行的项目。 I assume I was right to add the GWT run-target, because before I do that the Run menu is entirely grayed out. 我假设我是正确的添加GWT运行目标,因为在我这样做之前,运行菜单完全变灰。 I believe it is grayed out because there are no modules listed in the modules list for the GWT facet. 我认为它是灰色的,因为GWT方面的模块列表中没有列出模块。

在此输入图像描述

I assume that I must create a new Run/Debug configuration which must be one of the following, and GWT made some sense since vaadin is based atop GWT: 我假设我必须创建一个新的运行/调试配置,它必须是以下之一,并且由于vaadin基于GWT,因此GWT有一定意义:

在此输入图像描述

After I add the GWT I still get the same error as I got originally when I started from the maven archetype: No GWT modules. 在我添加GWT之后,我仍然得到与我从maven原型开始时最初的错误:没有GWT模块。 And I have no idea what people are talking about picking from a drop down module... 我不知道人们在谈论从下拉模块中挑选什么...

在此输入图像描述

Update3 Still was unable to get either solution below to work. Update3仍然无法让下面的任何一个解决方案工作。 Stuck at this screen and unable to get it to show any modules in the "GWT modules to load" combo box which remains grayed out. 卡在此屏幕上,无法显示“要加载的GWT模块”组合框中的任何模块,该组合框仍然显示为灰色。 I believe this is the drop down module that I am supposed to pick, but nothing below tells me how to get it to be un-grayed-out (enabled): 我相信这是我应该选择的下拉模块,但下面没有任何内容告诉我如何让它变为灰色(启用):

在此输入图像描述

I eventually managed to (a) add the GWT facet manually, (b) configure it, and (c) now it will run. 我最终设法(a)手动添加GWT方面,(b)配置它,(c)现在它将运行。 That leads to a runtime error (the app does not open in the web browser, but it is clear that it's very close to working.) 这会导致运行时错误(应用程序无法在Web浏览器中打开,但很明显它非常接近工作。)

Here's how I did this. 这就是我这样做的方式。

First create the Vaadin project using the maven artefact. 首先使用maven artefact创建Vaadin项目。

C:\dev> mvn archetype:generate -DarchetypeGroupId=com.vaadin -DarchetypeArtifactId=vaadin-archetype-application -DarchetypeVersion=7.0.4 -Dpackaging=war
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[INFO] Archetype repository missing. Using the one from [com.vaadin:vaadin-archetype-application:7.0.4] found in catalog remote
Define value for property 'groupId': : maba
Define value for property 'artifactId': : vaadin-app
Define value for property 'version':  1.0-SNAPSHOT: :
Define value for property 'package':  maba: :
Confirm properties configuration:
groupId: maba
artifactId: vaadin-app
version: 1.0-SNAPSHOT
package: maba
 Y: :
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: vaadin-archetype-application:7.0.4
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: maba
[INFO] Parameter: artifactId, Value: vaadin-app
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: maba
[INFO] Parameter: packageInPathFormat, Value: maba
[INFO] Parameter: package, Value: maba
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: groupId, Value: maba
[INFO] Parameter: artifactId, Value: vaadin-app
[INFO] project created from Archetype in dir: C:\dev\vaadin-app
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 28.122s
[INFO] Finished at: Fri Apr 19 08:05:49 CEST 2013
[INFO] Final Memory: 12M/152M
[INFO] ------------------------------------------------------------------------
C:\dev>

Then step into the newly created directory and run mvn install just to get all dependencies and have a fresh start. 然后进入新创建的目录并运行mvn install以获取所有依赖项并重新开始。

c:\dev\vaadin-app> mvn install
[INFO] Scanning for projects...
    ...
    ------ LOTS OF STUFF GOING ON ------
    ...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3:30.373s
[INFO] Finished at: Fri Apr 19 08:13:07 CEST 2013
[INFO] Final Memory: 24M/296M
[INFO] ------------------------------------------------------------------------

Now open the project by pointing to the newly created pom.xml . 现在通过指向新创建的pom.xml来打开项目。

在此输入图像描述

Everything looks fine. 一切都很好看。 Choose to configure the GWT framework in the green box in the upper right corner. 选择在右上角的绿色框中配置GWT框架。

在此输入图像描述

Now choose the Edit Configurations... drop-down. 现在选择Edit Configurations...下拉列表。

在此输入图像描述

Choose the GWT Configuration . 选择GWT Configuration

在此输入图像描述

Give it a name and choose the Module from the drop-down. 为其命名,然后从下拉列表中选择“ Module ”。

在此输入图像描述

Now you will have the option to choose GWT Module to load with two options at the moment. 现在,您可以选择GWT Module to load两个选项。

在此输入图像描述

I choose to run the application. 我选择运行该应用程序。 In this case it will give you an error. 在这种情况下,它会给你一个错误。

在此输入图像描述

This seems to be a known error at the moment. 这似乎是目前已知的错误 You'll have to add the vaadin-client-compiler.jar to classpath manually. 您必须手动将vaadin-client-compiler.jar到类路径中。

Press the Project Structure button in the toolbar. 按工具栏中的“ Project Structure按钮。

在此输入图像描述

Select Dependencies tab for the vaadin-app and choose to add Jars or directories... . 选择vaadin-app Dependencies选项卡,然后选择添加Jars or directories...

在此输入图像描述

Navigate to your local maven repository and find the vaadin-client-compiler-<version>.jar . 导航到本地maven存储库并找到vaadin-client-compiler-<version>.jar

On Mac OS and Linux/Unix, this will found at: ~/.m2/repository/com/vaadin/vaadin-client-compiler/7.0.4/... 在Mac OS和Linux / Unix上,可以在以下位置找到: ~/.m2/repository/com/vaadin/vaadin-client-compiler/7.0.4/...

在此输入图像描述

Press Ok and Ok again in the Project Structure window. 在“ Project Structure窗口中再次按“ Ok和“ Ok

Now once again run the application. 现在再次运行应用程序。 No more errors. 没有更多的错误。

在此输入图像描述


Now, I'm not a Vaadin expert so from here you're on your own. 现在,我不是Vaadin专家,所以从这里开始你就是自己。

Have fun! 玩得开心!

Using the Vaadin Plugin: 使用Vaadin插件:

New Project, Select Java Module - enter project name and location then click next. 新建项目,选择Java模块 - 输入项目名称和位置,然后单击下一步。

Select "Web Application" and "Vaadin Application", check "Create Sample vaad application" and enter a class name. 选择“Web Application”和“Vaadin Application”,选中“Create Sample vaad application”并输入类名。 Select a vaadin version. 选择一个vaadin版本。

Click finish. 点击完成。

Note that the generated example application will not compile (!) as I think it was from a beta version of Vaadin 7. 请注意,生成的示例应用程序将不会编译(!),因为我认为它来自Vaadin 7的测试版。

/* As Generated */
public class MySampleVaadinApplication extends UI {
  @Override
  public void init(VaadinRequest request) {
    Label label = new Label("Hello Vaadin user");
    addComponent(label);
 }
}

This is what it should look like 应该是它的样子

/* As it needs to be */
public class MySampleVaadinApplication extends UI {
  @Override
  public void init(VaadinRequest request) {
    Label label = new Label("Hello Vaadin user");
    setContent(label);
 }
}

Note that the Vaadin Plugin for intellij is not created or maintained by the Vaadin dev team, but by other(s) so it hasn't been kept up to date. 请注意,intellij的Vaadin插件不是由Vaadin开发团队创建或维护的,而是由其他人创建或维护的,所以它没有保持最新。 It is absolutely possible to develop Vaadin applications in IntelliJ without it - we do. 绝对有可能在没有它的情况下在IntelliJ中开发Vaadin应用程序 - 我们这样做。

I confess to being a total beginner at Java, IntellIJ, and Vaadin, not to mention GWT. 我承认自己是Java,IntellIJ和Vaadin的初学者,更不用说GWT了。

Good Luck - you've got a lot of stuff to get your head around! 祝你好运 - 你有很多东西可以解决这个问题!

选择Java模块选择“Web应用程序”和“Vaadin应用程序”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM