Vaadin std prod项目包括vaadin-client-compiler和jetty?

时间:2016-02-14 17:23:59

标签: maven vaadin

我的生产项目中包含了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以及不包含的内容。

enter image description here

我找到了this ticket并且通过查看最后一条评论,似乎我的生产WAR中不应该有这样的东西。我不愿意改变我的POM,因为它们是由原型生成的,我想在某种程度上应该代表一种Vaadin最佳实践方法。我不想再猜测一下。还是?

这些工件作为类路径的一部分的问题是

  1. 气球大小为WAR
  2. 它会产生一些Atmosphere的问题,因为它在类路径上找到了Jetty,所以它应该被混淆。 (气氛在Vaadin的引擎盖下使用)
  3. 结果是在Tomcat 8上部署时会在日志中出现类似SEVERE错误:

    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
    

    总结一下:

    1. 应该在a中有这些工件是否正确? Vaadin 7.6.2生产项目?
    2. 如何解决?

2 个答案:

答案 0 :(得分:2)

我相信我找到了答案。似乎Vaadin团队已经/完全意识到这一点,但是从过去发生某种烦人的错误来看,这是一种遗留问题。

在您的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评论所说的,这已经没有任何正当理由了。目前,每次生成新的项目框架时,您都必须手动更正它。

答案 1 :(得分:0)

如果您使用其他网络服务器(在您的情况下为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>

此外删除/评论所有不必要的&#34;码头&#34;在模块POM文件中找到的依赖项。