java.lang.NoClassDefFoundError:org/springframework/data/gemfire/util/SpringExtensions - Spring Gemfire

问题描述 投票:0回答:1

我正在使用 Apache Geode 开发一个简单的 CRUD 应用程序。我用下面的方法来启动 Gemfire

docker run -it apachegeode/geode

错误:

java.lang.NoClassDefFoundError: org/springframework/data/gemfire/util/SpringExtensions
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at org.springframework.geode.boot.autoconfigure.RegionTemplateAutoConfiguration.lambda$setAutoConfiguredRegionTemplateDependencies$3(RegionTemplateAutoConfiguration.java:215)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    at java.base/java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1620)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
    at org.springframework.geode.boot.autoconfigure.RegionTemplateAutoConfiguration.setAutoConfiguredRegionTemplateDependencies(RegionTemplateAutoConfiguration.java:215)
    at org.springframework.geode.boot.autoconfigure.RegionTemplateAutoConfiguration.lambda$regionTemplateBeanFactoryPostProcessor$0(RegionTemplateAutoConfiguration.java:144)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:325)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:198)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:746)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:564)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
    at com.example.gemfirebasic.Application.main(Application.java:19)
Caused by: java.lang.ClassNotFoundException: org.springframework.data.gemfire.util.SpringExtensions
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 31 common frames omitted

pom.xml

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.1</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>00-gemfire-basic</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>00-gemfire-basic</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>11</java.version>
        <spring-geode.version>1.7.5</spring-geode.version>
    </properties>
    
    <dependencies>
        <dependency>
            <groupId>org.springframework.geode</groupId>
            <artifactId>spring-geode-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.geode</groupId>
            <artifactId>spring-geode-starter-session</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.geode</groupId>
            <artifactId>spring-geode-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.geode</groupId>
            <artifactId>spring-geode-starter-logging</artifactId>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.geode</groupId>
                <artifactId>spring-geode-bom</artifactId>
                <version>${spring-geode.version}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

客户.java

@Region("Customers")
@RequiredArgsConstructor(staticName = "create")
@NoArgsConstructor
@Data
public class Customer {

    @Id
    @NonNull
    private Long id;

    @NonNull
    private String name;
}

CustomerRepository.java 公共接口 CustomerRepository 扩展了 CrudRepository {

    Customer findByNameLike(String name);
}

MainApp.java

@SpringBootApplication
@EnableEntityDefinedRegions(basePackageClasses = Customer.class, clientRegionShortcut = ClientRegionShortcut.LOCAL)
public class Application implements CommandLineRunner {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Autowired
    private CustomerRepository customerRepository;

    @Override
    public void run(String... args) throws Exception {
        Customer c1 = Customer.create(1L, "John Doe");
        Customer c2 = Customer.create(2L, "Jane Doe");
        Customer c3 = Customer.create(3L, "Jack Doe");
        Customer c4 = Customer.create(4L, "Mike Doe");
        Customer c5 = Customer.create(5L, "Matt Doe");

        customerRepository.saveAll(Arrays.asList(c1, c2, c3, c4, c5));

        customerRepository.findAll().forEach(System.out::println);
    }
}
spring gemfire geode
1个回答
0
投票

查看 Spring Data for Geode 的 1.7.5 版本的依赖项,它至少需要 Spring Boot 2.7.5。您正在使用 Spring Boot 2.7.1,目前它会导致为 Spring 和 Spring Boot 引入不同的 jar,我怀疑会导致版本不兼容。 因此要修复升级到最新的 Spring Boot 2.7 版本。

© www.soinside.com 2019 - 2024. All rights reserved.