Skip to content

Error creating bean with name 'redisEnhancedMappingContext #705

@timurturbil

Description

@timurturbil

I am trying to integrate redis-om to a library which is for spring projects but I got an error and did not get it why it happens. (using latest version 2.0.1) (I was using 1.0.4 version but did not get this error there. Once update version I started to get it)

When I run my test with redis-om integration I got the error:

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisEnhancedMappingContext' defined in com.redis.om.spring.RedisModulesConfiguration: Post-processing of merged bean definition failed.

It would be very helpful for me if you give me any clue or something.

Here all of my configs and businesses.

@Repository
public interface TxRedisDocumentRepository
        extends RedisDocumentRepository<TransactionLogDocument, String> {
}
@Document
public class TransactionLogDocument {

    @Id
    private String id;

    @Indexed
    private Integer txId;

    @Searchable
    private String method;

    @Indexed
    private String propagation;

    @Indexed
    private String isolation;

    @Indexed
    private Instant startTime;

    @Indexed
    private Instant endTime;

    public TransactionLogDocument() {
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Integer getTxId() {
        return txId;
    }

    public void setTxId(Integer txId) {
        this.txId = txId;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getPropagation() {
        return propagation;
    }

    public void setPropagation(String propagation) {
        this.propagation = propagation;
    }

    public String getIsolation() {
        return isolation;
    }

    public void setIsolation(String isolation) {
        this.isolation = isolation;
    }

    public Instant getStartTime() {
        return startTime;
    }

    public void setStartTime(Instant startTime) {
        this.startTime = startTime;
    }

    public Instant getEndTime() {
        return endTime;
    }

    public void setEndTime(Instant endTime) {
        this.endTime = endTime;
    }
}
@EnableRedisDocumentRepositories(
        basePackages = {
                "com.sdlc.pro.txboard.repository",
                "com.sdlc.pro.txboard.model"
        }
)
public class TxBoardRedisOMAutoConfiguration {

    @Primary
    @Bean
    public JedisConnectionFactory jedisConnectionFactory() {
        String host = "localhost";
        int port = 6379;
        String password = "mypassword";
        RedisStandaloneConfiguration config = new RedisStandaloneConfiguration(host, port);
        config.setPassword(password);

        return new JedisConnectionFactory(config);
    }
}
public final class RedisTransactionLogRepositoryCopy {
    
    private final TxRedisDocumentRepository redisRepository;

    public RedisTransactionLogRepositoryCopy(TxRedisDocumentRepository redisRepository) {
        this.redisRepository = redisRepository;
    }

    public void save(TransactionLogDocument log){
        redisRepository.save(document);
    }

    public void deleteAll(){
        redisRepository.deleteAll();
    }

    public List<TransactionLogDocument> findAll(){
        return redisRepository.findAll().stream()
                .toList();
    }
}
@SpringBootTest(classes = {
        RedisAutoConfiguration.class,
        RedisModulesConfiguration.class,
        TxBoardRedisOMAutoConfiguration.class,
})
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class RedisTransactionLogRepositoryCopyTest2 {

    @Autowired
    TxRedisDocumentRepository repo;

    @BeforeAll
    void setup() throws IOException {
        RedisTransactionLogRepositoryCopy logRepo = new RedisTransactionLogRepositoryCopy(repo);
        logRepo.deleteAll();
            for (TransactionLogDocument transactionLog : TxLogUtils.createTestTransactionLogs()) {
                logRepo.save(transactionLog);
            }
    }

    @Test
    void testFindAll() {
        RedisTransactionLogRepositoryCopy logRepo = new RedisTransactionLogRepositoryCopy(repo);
        List<TransactionLogDocument> transactionLogs = logRepo.findAll();
        assertThat(transactionLogs).isNotNull();
        assertThat(transactionLogs.size()).isEqualTo(6);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions