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

启动Spring Vaadin Web应用时spring-boot-maven-plugin报错

Fixing NoClassDefFoundError: org/springframework/boot/CommandLineRunner in Vaadin CRUD Spring Boot App

Hey there, let's work through this error you're facing when running spring-boot:run! That NoClassDefFoundError typically points to a classpath issue—either a missing dependency, version mismatch, or cached build artifact causing problems. Here are the steps I'd take to fix it:

  • Update your Spring Boot version
    Spring Boot 2.0.0.RELEASE is quite outdated (it's from 2018), and it might not be compatible with the Vaadin version the tutorial uses. Try upgrading to a more recent, stable release that works with your Vaadin setup. For example, if you're using Vaadin 14+, Spring Boot 2.7.x is a solid choice. Update the parent version in your pom.xml:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.15</version>
        <relativePath/>
    </parent>
    
  • Validate your Vaadin dependencies
    Make sure you've got the correct Vaadin starter in your pom.xml—this ensures all required Vaadin and Spring Boot integrations are included:

    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-spring-boot-starter</artifactId>
    </dependency>
    

    Double-check that your Vaadin version aligns with your chosen Spring Boot version (older Vaadin releases won't work with newer Spring Boot, and vice versa).

  • Clean and rebuild your project
    Cached dependencies or build artifacts often cause weird classpath issues. Run these commands to wipe old builds and refresh dependencies:

    mvn clean
    mvn install
    

    Then try running mvn spring-boot:run again.

  • Check for conflicting dependencies
    Use the mvn dependency:tree command to generate a list of all your project's dependencies. Look for multiple versions of Spring Boot core libraries (like spring-boot-starter or spring-boot-autoconfigure)—conflicts here can break the classpath. If you find mismatches, you may need to exclude conflicting dependencies from your pom or align versions.

  • Verify your CommandLineRunner implementation
    If you've added a custom class that implements CommandLineRunner, make sure it's properly annotated with @Component (or that your main application class implements it and is annotated with @SpringBootApplication). Also, double-check your imports—typos here can lead to the JVM looking for the wrong class.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 11:47:22