You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vaadin项目执行mvn compile时出现MojoException编译错误求助

Troubleshooting Vaadin 8 + Spring Boot Compilation & Deployment Issues

Hey there, let's break down your problems step by step—first fixing that mvn compile Mojo error, then setting up automatic view class compilation so you don't have to manually copy JARs around.

First: Diagnosing the Mojo Error

Mojo errors during mvn compile almost always tie to misconfigured Vaadin Maven plugin settings or version mismatches. Here's what to check first:

  • Verify plugin-version alignment: Make sure your vaadin-maven-plugin version exactly matches your Vaadin 8 core version. For example, if you're using Vaadin 8.14.3, the plugin should also be on 8.14.3—mismatched versions often cause compilation failures.
  • Enable debug logging: Run mvn clean compile -X to get full, detailed error logs. The -X flag will show exactly which Mojo is failing and why (e.g., widgetset compilation issues, missing dependencies, or classpath conflicts). This is critical for pinpointing the root cause.
  • Check Spring Boot compatibility: Vaadin 8 only works with Spring Boot 2.x (since Spring Boot 3+ drops Java 8 support, which Vaadin 8 relies on). If you're using Spring Boot 3.x, roll back to a 2.x version like 2.7.15.

Automating View Class Compilation (No Manual JAR Copies!)

You don't need to manually compile view classes into JARs and move them to app>Webapp>WEB-INF>classes—the Vaadin Maven plugin handles this automatically when configured correctly. Here's how to set it up:

Key POM Configurations

Ensure your pom.xml includes these critical sections (adjust versions to match your project):

<dependencies>
    <!-- Vaadin 8 Spring Boot Starter -->
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-spring-boot-starter</artifactId>
        <version>8.14.3</version> <!-- Match your Vaadin 8 version -->
    </dependency>
    <!-- Mark Tomcat starter as provided for external deployment -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <!-- Spring Boot Maven Plugin -->
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.7.15</version> <!-- Compatible with Vaadin 8 -->
        </plugin>
        <!-- Vaadin Maven Plugin: Automates view/widgetset compilation -->
        <plugin>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-maven-plugin</artifactId>
            <version>8.14.3</version> <!-- Match Vaadin core version -->
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal> <!-- Automatically compiles view classes -->
                        <goal>update-theme</goal>
                        <goal>update-widgetset</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

How It Works

When you run mvn package to build your WAR:

  1. The Vaadin plugin's compile goal processes your view classes, compiles them, and places the output in the correct location within the WAR (no manual copying needed).
  2. The Spring Boot plugin packages everything into a deployable WAR that's ready for Tomcat.

Next Steps to Fix Your Issue

  1. Double-check your POM against the example above—fix any version mismatches or missing plugin executions.
  2. Run mvn clean vaadin:compile compile to manually trigger Vaadin's compilation first, then standard compilation. This can isolate whether the issue is with Vaadin's plugin or general Maven setup.
  3. If you still get the Mojo error, share the relevant snippet from the mvn compile -X logs—this will let us pinpoint exactly what's breaking.

内容的提问来源于stack exchange,提问作者James Palfrey

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 09:47:06