Skip to content
TheChatArchiveThe Chat Archive
Hunyuanhunyuan-turbos-20250416· TencentHugging Face LMArena Human Preference 140K

Show example vaadin app without springboot

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Qwenqwen3-235b-a22b-no-thinking’s answer.
  1. User

    Show example vaadin app without springboot

  2. Hunyuan Assistant

    Certainly! Below is a complete, minimal example of a Vaadin application that does NOT use Spring Boot, suitable for deployment on a Java EE server like WildFly.


    ✅ Goal:

    Create a simple Vaadin app that displays "Hello, Vaadin!" on a webpage, packaged as a WAR, and deployable to WildFly (or any Java EE-compatible server).


    📦 1. Project Structure

    my-vaadin-app/
    ├── src/
    │   └── main/
    │       ├── java/
    │       │   └── com/example/myapp/
    │       │       └── MainView.java
    │       ├── webapp/
    │       │   └── WEB-INF/
    │       │       └── web.xml
    │       └── resources/
    │           └── META-INF/
    │               └── MANIFEST.MF
    ├── pom.xml
    

    🔸 You can skip the web.xml and use annotations instead, but we'll include it here for completeness.


    🧩 2. Add Vaadin Dependency (Maven)

    <!-- pom.xml -->
    <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</groupId>
        <artifactId>my-vaadin-app</artifactId>
        <version>1.0.0</version>
        <packaging>war</packaging>
    
        <properties>
            <vaadin.version>24.0.0</vaadin.version> <!-- Use latest -->
            <failOnMissingWebXml>false</failOnMissingWebXml> <!-- Optional -->
        </properties>
    
        <dependencies>
            <!-- Vaadin Core (no Spring) -->
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-core</artifactId>
                <version>${vaadin.version}</version>
            </dependency>
        </dependencies>
    
        <build>
            <plugins>
                <!-- Java 11+ Compiler -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.11.0</version>
                    <configuration>
                        <source>17</source>
                        <target>17</target>
                    </configuration>
                </plugin>
    
                <!-- WAR packaging -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>3.3.2</version>
                </plugin>
            </plugins>
        </build>
    </project>
    

    🖼️ 3. Create the Main View (UI Component)

    // src/main/java/com/example/myapp/MainView.java
    package com.example.myapp;
    
    import com.vaadin.flow.component.html.Label;
    import com.vaadin.flow.component.orderedlayout.VerticalLayout;
    import com.vaadin.flow.router.Route;
    
    @Route("") // This is the root URL (http://localhost:8080/my-vaadin-app/)
    public class MainView extends VerticalLayout {
    
        public MainView() {
            add(new Label("Hello, Vaadin without Spring Boot!"));
        }
    }
    

    ⚠️ Note: If you're using Vaadin 23+, the @Route annotation is part of com.vaadin.flow.router.Route. Make sure you're using the correct package.


    🌐 4. Configure web.xml (Optional but Supported)

    <!-- src/main/webapp/WEB-INF/web.xml -->
    <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
                                 http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
             version="4.0">
    
        <servlet>
            <servlet-name>UI</servlet-name>
            <servlet-class>com.vaadin.flow.server.VaadinServlet</servlet-class>
        </servlet>
    
        <servlet-mapping>
            <servlet-name>UI</servlet-name>
            <url-pattern>/*</url-pattern>
        </servlet-mapping>
    
        <session-config>
            <session-timeout>30</session-timeout>
        </session-config>
    </web-app>
    

    ✅ Alternative (recommended): If you're using Vaadin 23+, you can omit the web.xml and use the @WebServlet annotation instead:

    @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
    @VaadinServletConfiguration(ui = MainView.class, productionMode = false)
    public class MyUIServlet extends VaadinServlet {
    }
    

    But for simplicity, we’ll use @Route + web.xml in this example.


    🗂️ 5. Create a MANIFEST.MF (Optional)

    # src/main/resources/META-INF/MANIFEST.MF
    Manifest-Version: 1.0
    Created-By: Maven
    

    You can omit this unless you're targeting a specific servlet container or need metadata.


    🚀 6. Build the Application

    Use Maven to build the WAR:

    mvn clean package
    

    This creates a target/my-vaadin-app-1.0.0.war file.


    🛠️ 7. Deploy to WildFly

    1. Copy the WAR file to:

      $WILDFLY_HOME/standalone/deployments/
      
    2. Start WildFly:

      ./standalone.sh  # or standalone.bat on Windows
      
    3. Open your browser:

      http://localhost:8080/my-vaadin-app-1.0.0/
      

      You should see:
      Hello, Vaadin without Spring Boot!


    🎉 Summary

    ✅ You now have a working Vaadin application without Spring Boot, deployable on WildFly.

    ✅ Key Takeaways:

    • Vaadin is independent of Spring Boot.
    • You can deploy Vaadin apps to any Java EE server.
    • Vaadin 23+ uses @Route for navigation.
    • You can use web.xml or @WebServlet to configure the servlet.

    If you'd like, I can also show you how to add Vaadin login or connect to a database (without Spring). Let me know!

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.