代码之家  ›  专栏  ›  技术社区  ›  Basil Bourque

使Maven驱动的Vaadin 8.5项目适应于Jakarta EE兼容服务器

  •  0
  • Basil Bourque  · 技术社区  · 6 年前

    Vaadin 8.5.2 使用创建的应用程序 vaadin-archetype-application Maven原型 provided by 瓦丁有限公司 公司可以:

    • 访问指定的类 Jakarta EE
    • 部署到符合Jakarta EE的服务器

    一个例子 Glassfish 可能是最好的,但我也很好奇看到任何其他兼容服务器。

    Concurrency Utilities 1.0 (JSR 168) (作为 listed here )在我的Vaadin网络应用程序中。但我的问题更一般。

    我要求在Maven POM中进行所需的配置更改。将符合Jarkata EE的服务器附加到IDE以运行调试不在本问题的讨论范围内,因为该问题可能已经在堆栈溢出上讨论过了,并且不是Vaadin特有的。

    Java 11 或者以后,以及所需的 modularization ,好多了。

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>com.basilbourque.example</groupId>
        <artifactId>trash-me-8</artifactId>
        <packaging>war</packaging>
        <version>1.0-SNAPSHOT</version>
        <name>trash-me-8</name>
    
        <prerequisites>
            <maven>3</maven>
        </prerequisites>
    
        <properties>
            <vaadin.version>8.5.2</vaadin.version>
            <vaadin.plugin.version>8.5.2</vaadin.plugin.version>
            <jetty.plugin.version>9.3.9.v20160517</jetty.plugin.version>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
            <!-- If there are no local customizations, this can also be "fetch" or "cdn" -->
            <vaadin.widgetset.mode>local</vaadin.widgetset.mode>
        </properties>
    
        <repositories>
            <repository>
                <id>vaadin-addons</id>
                <url>http://maven.vaadin.com/vaadin-addons</url>
            </repository>
        </repositories>
    
        <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>com.vaadin</groupId>
                    <artifactId>vaadin-bom</artifactId>
                    <version>${vaadin.version}</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
            </dependencies>
        </dependencyManagement>
    
        <dependencies>
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>3.0.1</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-server</artifactId>
            </dependency>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-push</artifactId>
            </dependency>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-client-compiled</artifactId>
            </dependency>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-themes</artifactId>
            </dependency>
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>3.2.0</version>
                    <configuration>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                        <!-- Exclude an unnecessary file generated by the GWT compiler. -->
                        <packagingExcludes>WEB-INF/classes/VAADIN/widgetsets/WEB-INF/**</packagingExcludes>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>com.vaadin</groupId>
                    <artifactId>vaadin-maven-plugin</artifactId>
                    <version>${vaadin.plugin.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>update-theme</goal>
                                <goal>update-widgetset</goal>
                                <goal>compile</goal>
                                <!-- Comment out compile-theme goal to use on-the-fly theme compilation -->
                                <goal>compile-theme</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>3.0.0</version>
                    <!-- Clean up also any pre-compiled themes -->
                    <configuration>
                        <filesets>
                            <fileset>
                                <directory>src/main/webapp/VAADIN/themes</directory>
                                <includes>
                                    <include>**/styles.css</include>
                                    <include>**/styles.scss.cache</include>
                                </includes>
                            </fileset>
                        </filesets>
                    </configuration>
                </plugin>
    
                <!-- The Jetty plugin allows us to easily test the development build by
                    running jetty:run on the command line. -->
                <plugin>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-maven-plugin</artifactId>
                    <version>${jetty.plugin.version}</version>
                    <configuration>
                        <scanIntervalSeconds>2</scanIntervalSeconds>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    
        <profiles>
            <profile>
                <!-- Vaadin pre-release repositories -->
                <id>vaadin-prerelease</id>
                <activation>
                    <activeByDefault>false</activeByDefault>
                </activation>
    
                <repositories>
                    <repository>
                        <id>vaadin-prereleases</id>
                        <url>http://maven.vaadin.com/vaadin-prereleases</url>
                    </repository>
                    <repository>
                        <id>vaadin-snapshots</id>
                        <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
                        <releases>
                            <enabled>false</enabled>
                        </releases>
                        <snapshots>
                            <enabled>true</enabled>
                        </snapshots>
                    </repository>
                </repositories>
                <pluginRepositories>
                    <pluginRepository>
                        <id>vaadin-prereleases</id>
                        <url>http://maven.vaadin.com/vaadin-prereleases</url>
                    </pluginRepository>
                    <pluginRepository>
                        <id>vaadin-snapshots</id>
                        <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
                        <releases>
                            <enabled>false</enabled>
                        </releases>
                        <snapshots>
                            <enabled>true</enabled>
                        </snapshots>
                    </pluginRepository>
                </pluginRepositories>
            </profile>
        </profiles>
    
    </project>
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   Luqman    6 年前

    要在雅加达EE中使用Vaadin,您需要 Vaadin CDI addon 把这两种技术连接起来。这是能够使用Jakarta EE作为后端的最佳方法。然后可以使用任何与EE兼容的应用服务器。

    Vaadin project starter generator

    <?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.example.test</groupId>
        <artifactId>my-starter-project</artifactId>
        <name>My Starter Project</name>
        <version>1.0-SNAPSHOT</version>
        <packaging>war</packaging>
    
        <properties>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
            <failOnMissingWebXml>false</failOnMissingWebXml>
    
            <webapp.directory>src/main/webapp</webapp.directory>
    
            <!-- Dependencies -->
            <vaadin.version>12.0.0</vaadin.version>
        </properties>
    
        <pluginRepositories>
            <!-- Repository needed for prerelease versions of Vaadin -->
            <pluginRepository>
                <id>vaadin-prereleases</id>
                <url>https://maven.vaadin.com/vaadin-prereleases</url>
            </pluginRepository>
        </pluginRepositories>
    
        <repositories>
            <!-- Repository needed for prerelease versions of Vaadin -->
            <repository>
                <id>vaadin-prereleases</id>
                <url>https://maven.vaadin.com/vaadin-prereleases</url>
            </repository>
            <!-- Repository used by many Vaadin add-ons -->
            <repository>
                 <id>Vaadin Directory</id>
                 <url>http://maven.vaadin.com/vaadin-addons</url>
            </repository>
        </repositories>
    
        <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>com.vaadin</groupId>
                    <artifactId>vaadin-bom</artifactId>
                    <version>${vaadin.version}</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
            </dependencies>
        </dependencyManagement>
    
        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-core</artifactId>
            </dependency>
    
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-cdi</artifactId>
                <version>10.0.0.beta1</version>
            </dependency>
            <dependency>
                <groupId>javax</groupId>
                <artifactId>javaee-api</artifactId>
                <version>8.0</version>
                <scope>provided</scope>
            </dependency>
    
            <!-- Added to provide logging output as Flow uses -->
            <!-- the unbound SLF4J no-operation (NOP) logger implementation -->
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-simple</artifactId>
            </dependency>
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.tomee.maven</groupId>
                    <artifactId>tomee-maven-plugin</artifactId>
                    <version>7.0.4</version>
                    <configuration>
                        <tomeeClassifier>webprofile</tomeeClassifier>
                        <context>ROOT</context>
                    </configuration>
                </plugin>
    
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>3.0.0</version>
                    <configuration>
                        <filesets>
                            <fileset>
                                <directory>${webapp.directory}/frontend-es5</directory>
                            </fileset>
                            <fileset>
                                <directory>${webapp.directory}/frontend-es6</directory>
                            </fileset>
                        </filesets>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    
        <profiles>
            <profile>
                <id>productionMode</id>
                <activation>
                    <property>
                        <name>vaadin.productionMode</name>
                    </property>
                </activation>
    
                <dependencies>
                    <dependency>
                        <groupId>com.vaadin</groupId>
                        <artifactId>flow-server-production-mode</artifactId>
                    </dependency>
                </dependencies>
    
                <build>
                    <plugins>
                        <plugin>
                            <groupId>com.vaadin</groupId>
                            <artifactId>vaadin-maven-plugin</artifactId>
                            <version>${vaadin.version}</version>
                            <executions>
                                <execution>
                                    <phase>prepare-package</phase>
                                    <goals>
                                        <goal>copy-production-files</goal>
                                        <goal>package-for-production</goal>
                                    </goals>
                                    <configuration>
                                        <transpileOutputDirectory>${webapp.directory}</transpileOutputDirectory>
                                    </configuration>
                                </execution>
                            </executions>
                        </plugin>
    
                    </plugins>
                </build>
            </profile>
        </profiles>
    </project>
    

    你可以调整它以适应你的需要。它是基于Vaadin 12的,但是你可以做一些小的修改,让它与8一起工作。