Vaadin std prod 项目包括 vaadin-client-compiler 和 jetty?
Vaadin std prod project includes vaadin-client-compiler and jetty?
我的生产项目中包含了 vaadin-client-compiler
个工件(其中包含 Jetty)。我应该吗?
为了重现,我从头开始让 Maven 为我生成一个 Vaadin 多模块项目:
mvn
-DarchetypeGroupId=com.vaadin
-DarchetypeArtifactId=vaadin-archetype-application-multimodule
-DarchetypeVersion=7.6.2
-DarchetypeRepository=http://repo.maven.apache.org/maven2/
-DgroupId=com.acme
-DartifactId=VaadinTest1
-Dversion=1.0.0-SNAPSHOT
-Dpackage=com.acme.vaadintest1
-Dbasedir=D:\dev\java
-DthemeName=mytheme
-DwidgetsetName=MyAppWidgetset
-DuiName=MyUI
-Darchetype.interactive=false
--batch-mode archetype:generate
然后在父项目中我执行:
mvn -Pproduction clean install
完成后,我查看在 "xxx-production" 项目中生成的 WAR 文件,发现它包含 vaadin-client-compiler、Jetty 等等。
我发现 this ticket 并且通过查看最后一条评论,我似乎不应该在我的作品中使用类似的东西 WAR。我对更改我的 POM 犹豫不决,因为它们是由原型生成的,我想在某种程度上应该代表某种 Vaadin 最佳实践方法。我不想再猜测了。或者?
这些工件作为类路径的一部分的问题在于
- 它膨胀了 WAR
的大小
- 它在 Atmosphere 方面产生了一些问题,据推测这会让人感到困惑,因为它在类路径上找到了 Jetty。 (Vaadin 在后台使用了 Atmosphere)
结果是在 Tomcat 8:
上部署时,您将在日志中收到类似这样的严重错误
14-Feb-2016 16:42:30.368 SEVERE [localhost-startStop-1] org.atmosphere.cpr.DefaultAsyncSupportResolver.newCometSupport Failed to create comet support class: class org.
atmosphere.container.JettyServlet30AsyncSupportWithWebSocket, error: null
总结一下:
- 我 不 应该将这些工件放在
Vaadin 7.6.2 生产项目?
- 如何解决?
我相信我已经找到了答案。似乎 Vaadin 团队 was/is 完全意识到了这一点,但它有点像过去存在某种烦人的错误时遗留下来的东西。
在您的 xxx-widgetset
项目中,您会在该项目的 POM 中看到类似这样的内容:
<dependencies>
<!-- Versions for these are configured in the parent POM -->
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client</artifactId>
<!-- TODO this should have scope provided once http://dev.vaadin.com/ticket/14788 is resolved -->
<!-- <scope>provided</scope> -->
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiler</artifactId>
<!-- TODO this should have scope provided once http://dev.vaadin.com/ticket/14788 is resolved -->
<!-- <scope>provided</scope> -->
</dependency>
... you'll see more deps here if you've added
... Vaadin add-ons to your project.
</dependencies>
查看 TODO 评论 ??
好吧,碰巧ticket 14788中提到的错误不再发生,至少在7.6.2上不会。因此,您现在可以安全地按照 TODO 注释中的说明进行操作了。
这使我的 WAR 尺寸减少了 50-70 pct。
在我看来,没有任何充分的理由说明这个原型生成实际上没有按照 TODO 评论所说的去做。目前,每次生成新的项目框架时,您都必须手动更正它。
如果您使用不同的网络服务器(在您的情况下 Tomcat 8),则不需要提供的 jetty-plugin。
由于原型有一些码头依赖性,您可以使用
Maven POM 文件中的排除标记。
例子
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiler</artifactId>
<version>${vaadin.version}</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlets</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
</exclusion>
</exclusions>
此外 delete/comment 删除模块 POM 文件中发现的所有不必要的 "jetty" 依赖项。
我的生产项目中包含了 vaadin-client-compiler
个工件(其中包含 Jetty)。我应该吗?
为了重现,我从头开始让 Maven 为我生成一个 Vaadin 多模块项目:
mvn
-DarchetypeGroupId=com.vaadin
-DarchetypeArtifactId=vaadin-archetype-application-multimodule
-DarchetypeVersion=7.6.2
-DarchetypeRepository=http://repo.maven.apache.org/maven2/
-DgroupId=com.acme
-DartifactId=VaadinTest1
-Dversion=1.0.0-SNAPSHOT
-Dpackage=com.acme.vaadintest1
-Dbasedir=D:\dev\java
-DthemeName=mytheme
-DwidgetsetName=MyAppWidgetset
-DuiName=MyUI
-Darchetype.interactive=false
--batch-mode archetype:generate
然后在父项目中我执行:
mvn -Pproduction clean install
完成后,我查看在 "xxx-production" 项目中生成的 WAR 文件,发现它包含 vaadin-client-compiler、Jetty 等等。
我发现 this ticket 并且通过查看最后一条评论,我似乎不应该在我的作品中使用类似的东西 WAR。我对更改我的 POM 犹豫不决,因为它们是由原型生成的,我想在某种程度上应该代表某种 Vaadin 最佳实践方法。我不想再猜测了。或者?
这些工件作为类路径的一部分的问题在于
- 它膨胀了 WAR 的大小
- 它在 Atmosphere 方面产生了一些问题,据推测这会让人感到困惑,因为它在类路径上找到了 Jetty。 (Vaadin 在后台使用了 Atmosphere)
结果是在 Tomcat 8:
上部署时,您将在日志中收到类似这样的严重错误14-Feb-2016 16:42:30.368 SEVERE [localhost-startStop-1] org.atmosphere.cpr.DefaultAsyncSupportResolver.newCometSupport Failed to create comet support class: class org.
atmosphere.container.JettyServlet30AsyncSupportWithWebSocket, error: null
总结一下:
- 我 不 应该将这些工件放在 Vaadin 7.6.2 生产项目?
- 如何解决?
我相信我已经找到了答案。似乎 Vaadin 团队 was/is 完全意识到了这一点,但它有点像过去存在某种烦人的错误时遗留下来的东西。
在您的 xxx-widgetset
项目中,您会在该项目的 POM 中看到类似这样的内容:
<dependencies>
<!-- Versions for these are configured in the parent POM -->
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client</artifactId>
<!-- TODO this should have scope provided once http://dev.vaadin.com/ticket/14788 is resolved -->
<!-- <scope>provided</scope> -->
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiler</artifactId>
<!-- TODO this should have scope provided once http://dev.vaadin.com/ticket/14788 is resolved -->
<!-- <scope>provided</scope> -->
</dependency>
... you'll see more deps here if you've added
... Vaadin add-ons to your project.
</dependencies>
查看 TODO 评论 ?? 好吧,碰巧ticket 14788中提到的错误不再发生,至少在7.6.2上不会。因此,您现在可以安全地按照 TODO 注释中的说明进行操作了。
这使我的 WAR 尺寸减少了 50-70 pct。
在我看来,没有任何充分的理由说明这个原型生成实际上没有按照 TODO 评论所说的去做。目前,每次生成新的项目框架时,您都必须手动更正它。
如果您使用不同的网络服务器(在您的情况下 Tomcat 8),则不需要提供的 jetty-plugin。
由于原型有一些码头依赖性,您可以使用 Maven POM 文件中的排除标记。
例子
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiler</artifactId>
<version>${vaadin.version}</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlets</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
</exclusion>
</exclusions>
此外 delete/comment 删除模块 POM 文件中发现的所有不必要的 "jetty" 依赖项。