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

时间:2023-01-13 22:10:51

The answer based on the maven archetype approach works. I will update and accept an answer based on using the built in wizard if the IntelliJ wizard/template for Vaadin is ever fixed.*

基于maven原型方法的答案是有效的。如果用于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 facet,但是现在我运行它时,它说:

"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). I am using Ultimate, but it's a trial.

我还尝试使用本地Vaadin插件创建一个新的Vaadin projet,这个插件附带IntelliJ IDEA (Ultimate)。我用的是Ultimate,但这是一个尝试。

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

Update:: Originally I could not see any Vaadin projects in the New Project window's list of available project templates. That's because I was confused by the two-levels-of-new-projects idea in IntelliJ's new project wizard. Sorted that out now.

更新::最初,我在新项目窗口的可用项目模板列表中看不到任何Vaadin项目。那是因为我对IntelliJ的新项目向导中的两级新项目概念感到困惑。整理出来了。

Update2:: I can follow the steps from EITHER of the two answers below and get a project that builds but it doesn't run. I assume I was right to add the GWT run-target, because before I do that the Run menu is entirely grayed out. I believe it is grayed out because there are no modules listed in the modules list for the GWT facet.

Update2::我可以按照下面两个答案中的任何一个步骤,得到一个构建但不运行的项目。我认为添加GWT Run -target是正确的,因为在此之前,Run菜单是完全灰色的。我认为它是灰色的,因为在GWT方面的模块列表中没有列出模块。

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

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:

我假设我必须创建一个新的运行/调试配置,必须是以下配置之一,并且GWT有一定的意义,因为vaadin是基于GWT:

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

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. And I have no idea what people are talking about picking from a drop down module...

添加了GWT之后,我仍然会得到与开始使用maven原型时相同的错误:没有GWT模块。我不知道人们在说从下拉模块中挑选什么……

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

Update3 Still was unable to get either solution below to work. 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. 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):

Update3仍然无法得到下面的解决方案。在这个屏幕上,无法显示“GWT module to load”组合框中的任何模块,该组合框仍然是灰色的。我相信这是我应该选择的下拉模块,但是下面没有任何东西告诉我如何使它不灰度显示(启用):

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

I eventually managed to (a) add the GWT facet manually, (b) configure it, and (c) now it will run. 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.)

我最终设法(a)手动添加GWT facet, (b)配置它,(c)现在它将运行。这将导致运行时错误(该应用程序在web浏览器中没有打开,但很明显它非常接近于工作)。

2 个解决方案

#1


8  

Here's how I did this.

我是这样做的。

First create the Vaadin project using the maven artefact.

首先使用maven人工事实创建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安装,以获得所有依赖项并重新开始。

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打开项目。

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

Everything looks fine. Choose to configure the GWT framework in the green box in the upper right corner.

一切都看起来好。选择在右上角的绿色框中配置GWT框架。

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

Now choose the Edit Configurations... drop-down.

现在选择编辑配置…下拉。

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

Choose the GWT Configuration.

选择GWT配置。

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

Give it a name and choose the Module from the drop-down.

给它一个名称,并从下拉菜单中选择该模块。

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

Now you will have the option to choose GWT Module to load with two options at the moment.

现在,您可以选择使用GWT模块加载两个选项。

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

I choose to run the application. In this case it will give you an error.

我选择运行应用程序。在这种情况下,它会给你一个错误。

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

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.

按下工具栏中的项目结构按钮。

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

Select Dependencies tab for the vaadin-app and choose to add Jars or directories....

选择依赖vaadin-app选项卡,选择添加jar文件或目录....

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

Navigate to your local maven repository and find the vaadin-client-compiler-<version>.jar.

导航到本地maven存储库并找到vaadin-client-compiler- .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/... .

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

Press Ok and Ok again in the Project Structure window.

在“项目结构”窗口中再次单击“确定”和“确定”。

Now once again run the application. No more errors.

现在再次运行应用程序。没有更多的错误。

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


Now, I'm not a Vaadin expert so from here you're on your own.

现在,我不是一个Vaadin专家,所以从这里你是你自己的。

Have fun!

玩得开心!

#2


2  

Using the Vaadin Plugin:

使用Vaadin插件:

New Project, Select Java Module - enter project name and location then click next.

新建项目,选择Java模块——输入项目名称和位置,然后单击next。

Select "Web Application" and "Vaadin Application", check "Create Sample vaad application" and enter a class name. Select a vaadin version.

选择“Web应用程序”和“Vaadin应用程序”,检查“创建示例vaad应用程序”并输入类名。选择一个vaadin版本。

Click finish.

单击finish。

Note that the generated example application will not compile (!) as I think it was from a beta version of Vaadin 7.

注意,生成的示例应用程序不会编译(!),因为我认为它来自beta版本的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. It is absolutely possible to develop Vaadin applications in IntelliJ without it - we do.

注意,intellij的Vaadin插件不是由Vaadin dev团队创建或维护的,而是由其他人创建的,所以它还没有跟上时代。在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!

祝你好运——你有很多东西需要思考!

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

#1


8  

Here's how I did this.

我是这样做的。

First create the Vaadin project using the maven artefact.

首先使用maven人工事实创建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安装,以获得所有依赖项并重新开始。

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打开项目。

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

Everything looks fine. Choose to configure the GWT framework in the green box in the upper right corner.

一切都看起来好。选择在右上角的绿色框中配置GWT框架。

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

Now choose the Edit Configurations... drop-down.

现在选择编辑配置…下拉。

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

Choose the GWT Configuration.

选择GWT配置。

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

Give it a name and choose the Module from the drop-down.

给它一个名称,并从下拉菜单中选择该模块。

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

Now you will have the option to choose GWT Module to load with two options at the moment.

现在,您可以选择使用GWT模块加载两个选项。

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

I choose to run the application. In this case it will give you an error.

我选择运行应用程序。在这种情况下,它会给你一个错误。

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

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.

按下工具栏中的项目结构按钮。

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

Select Dependencies tab for the vaadin-app and choose to add Jars or directories....

选择依赖vaadin-app选项卡,选择添加jar文件或目录....

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

Navigate to your local maven repository and find the vaadin-client-compiler-<version>.jar.

导航到本地maven存储库并找到vaadin-client-compiler- .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/... .

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

Press Ok and Ok again in the Project Structure window.

在“项目结构”窗口中再次单击“确定”和“确定”。

Now once again run the application. No more errors.

现在再次运行应用程序。没有更多的错误。

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


Now, I'm not a Vaadin expert so from here you're on your own.

现在,我不是一个Vaadin专家,所以从这里你是你自己的。

Have fun!

玩得开心!

#2


2  

Using the Vaadin Plugin:

使用Vaadin插件:

New Project, Select Java Module - enter project name and location then click next.

新建项目,选择Java模块——输入项目名称和位置,然后单击next。

Select "Web Application" and "Vaadin Application", check "Create Sample vaad application" and enter a class name. Select a vaadin version.

选择“Web应用程序”和“Vaadin应用程序”,检查“创建示例vaad应用程序”并输入类名。选择一个vaadin版本。

Click finish.

单击finish。

Note that the generated example application will not compile (!) as I think it was from a beta version of Vaadin 7.

注意,生成的示例应用程序不会编译(!),因为我认为它来自beta版本的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. It is absolutely possible to develop Vaadin applications in IntelliJ without it - we do.

注意,intellij的Vaadin插件不是由Vaadin dev团队创建或维护的,而是由其他人创建的,所以它还没有跟上时代。在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!

祝你好运——你有很多东西需要思考!

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