未注入带有JPA2的Apache Ignite 2.7 IgniteRepository

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

使用基于Web的行会,我使用Spring Data JPA 2应用程序制作了简单的Spring Boot 2。 Spring Boot JPA 2支持仅在2.7版本中添加到Apache Ignite(现在仅在每晚构建时才可用-Apache Ignite 2.7 release date)。有代码片段:配置:

@Configuration

@ EnableIgniteRepositories公共类SpringDataConfig {

@Bean
public Ignite igniteInstance() {
    IgniteConfiguration config = new IgniteConfiguration();

    config.setIgniteInstanceName("ignite-1");
    config.setPeerClassLoadingEnabled(true);

    CacheConfiguration cache = new CacheConfiguration("usersCache");
    cache.setIndexedTypes(Integer.class, UserEntity.class);

    config.setCacheConfiguration(cache);
    Ignite ignite = Ignition.start(config);
    ignite.cluster().active(true);
    return ignite;
}}

存储库:

@RepositoryConfig(cacheName = "usersCache")
public interface UsersRepository extends IgniteRepository<UserEntity, Integer> {
    UserEntity getByUsername(String username);
}

和服务:

    @Service
public class UserServiceImpl implements UserService {
    @Autowired
//    UsersRepository repository;
    ApplicationContext context;

    @Override
    public UserEntity getByUsername(String username) {
        return context.getBean(UsersRepository.class).getByUsername(username);
    }}

运行时,我有以下例外:

[09:59:18] Ignite node started OK (id=8497f64c, instance name=ignite-1)
[09:59:18] Topology snapshot [ver=1, locNode=8497f64c, servers=1, clients=0, state=ACTIVE, CPUs=4, offheap=1.5GB, heap=1.7GB]
..

Caused by: java.lang.IllegalArgumentException: Failed to create query for method public abstract java.lang.Iterable org.apache.ignite.springdata20.repository.IgniteRepository.save(java.util.Map)! No property save found for type UserEntity!
    at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:82)
    at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:103)
    at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:208)
    at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:79)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lookupQuery(RepositoryFactorySupport.java:565)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$mapMethodsToQuery$1(RepositoryFactorySupport.java:558)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.Iterator.forEachRemaining(Iterator.java:116)
    at java.util.Collections$UnmodifiableCollection$1.forEachRemaining(Collections.java:1049)
    at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.mapMethodsToQuery(RepositoryFactorySupport.java:560)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$new$0(RepositoryFactorySupport.java:550)
    at java.util.Optional.map(Optional.java:215)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:550)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:323)
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$4(RepositoryFactoryBeanSupport.java:290)
    at org.springframework.data.util.Lazy.getNullable(Lazy.java:141)
    at org.springframework.data.util.Lazy.get(Lazy.java:63)
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:293)
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:102)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1758)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1695)
    ... 67 more
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property save found for type UserEntity!
    at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:94)
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:358)
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:334)
    at org.springframework.data.mapping.PropertyPath.lambda$from$0(PropertyPath.java:287)
    at java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:324)
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:269)
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:252)
    at org.springframework.data.repository.query.parser.Part.<init>(Part.java:81)
    at org.springframework.data.repository.query.parser.PartTree$OrPart.lambda$new$0(PartTree.java:250)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
    at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
    at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:251)
    at org.springframework.data.repository.query.parser.PartTree$Predicate.lambda$new$0(PartTree.java:380)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
    at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
    at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:381)
    at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:93)
    at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:76)
    ... 93 more

我的存储库中没有save *函数声明。仅getByUsername()。

  1. 如何解决该错误?
  2. 我如何连接几个点火节点并像单个数据库一样与他们合作?
  3. 我有现有的PostgreSQL数据库。我可以将它们与Ignite一起使用吗? (我正在查看ignite JDBC驱动程序,发现不存在PostgreSQL驱动程序,仅支持MySQL,SQL Server,H2等。但是有普通的JDBC驱动程序其中])。
  4. 此处描述的问题上下文:Which distributed database I need to choose for medium data project

使用基于Web的行会,我使用Spring Data JPA 2应用程序制作了简单的Spring Boot 2。 Spring Boot JPA 2支持仅在2.7版本中才添加到Apache Ignite(现在仅......>

java spring-boot spring-data-jpa ignite
1个回答
0
投票

我有同样的问题。当我们尝试同时使用JPA存储库和Ignite存储库时,Spring会将Ignite存储库视为JPA存储库,因为它也是从Repository接口扩展而来的。它尝试将IgniteRepository实现为JpaRepository,但由于使用的实体不是Jpa实体,因此将失败。

因此,我们需要从JpaRepository配置中排除IgniteRepository接口。为此,您可以在@SpringBootApplication注释下面添加注释。

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