skip to Main Content

I am upgrading an existing Spring Boot Project from 2.6.14 to 3.1.1. After my upgrade I am no longer able to connect to Redis using my cups in Tanzu Cloud Foundry. The cups is working for both Postgres and RMQ, but for some reason Redis is having an issue.

I put the external Redis connection details in application.properties and it works fine. When I remove this, however, it tries to connect to the local host default and is ignoring my Redis cups.

I tried adding @ImportAutoConfiguration and that did not help.

@SpringBootApplication
@EnableTransactionManagement
@EnableFeignClients
@EnableWebSecurity
@EnableAsync
@EnableRetry
@EnableCaching
@ImportAutoConfiguration({FeignAutoConfiguration.class,RedisAutoConfiguration.class})
public class Application {

This is my POM

<?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 http://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>3.1.1</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    
    <groupId>xxx.xxx.xxx.xxx</groupId>
    <artifactId>pcf-upgrade-api</artifactId>
    <version>1.0.0-RELEASE</version>
    <name>pcf-upgrade-api</name>
    <description>My 3.1 project</description>

    <properties>
        <java.version>17</java.version>
        <skip.it>true</skip.it>
        <spring-cloud.version>2022.0.3</spring-cloud.version>
        <sonar.coverage.exclusions>**/config/**/*, **/exceptions/**/*, **/dto/**/*, **/feign/client/**/*,
            **/Application.java</sonar.coverage.exclusions>
    </properties>

    <dependencies>
        
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        
         <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.3.0</version>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
        
        <dependency>
            <groupId>com.emc.it.cpe</groupId>
            <artifactId>cpe-common</artifactId>
            <version>2.0.0-SNAPSHOT</version>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.retry</groupId>
            <artifactId>spring-retry</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
                <artifactId>spring-aspects</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
        </dependency>
        
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
        </dependency>
        
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
        </dependency>
                    
        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-ui</artifactId>
            <version>1.6.14</version>
        </dependency>
                
        
        <!-- Swagger version 3.0.0 currently does not work with spring 2.6 
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>3.0.0</version>
        </dependency>
        
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>3.0.0</version>
        </dependency>  -->

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
                
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>
        
        <!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
        <dependency>
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
             <version>r05</version>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>       
        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        
        <!-- https://mvnrepository.com/artifact/org.springframework.integration/spring-integration-redis -->
        <dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-redis</artifactId>
        </dependency>
        
         <!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.5</version>
        </dependency>
        
        <dependency>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
            <version>2.0</version>
        </dependency>
        
        <dependency>
            <groupId>io.pivotal.cfenv</groupId>
            <artifactId>java-cfenv-boot</artifactId>
            <version>2.4.1</version>
        </dependency>
    </dependencies>
    
    
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.10</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>

                    <execution>
                        <id>report</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>    

                    </execution>
                </executions>
            </plugin>
            
        </plugins>
    </build>
</project>

Please let me know if anyone has any ideas or has faced a similar issue. Thank you!!!!

2

Answers


  1. redis configuration properties are now prefixed with spring.data.redis, they were previously prefixed spring.redis

    Login or Signup to reply.
  2. Have you tried version 3.x.x of java-cfenv with a spring3/java17 support ?

    https://github.com/pivotal-cf/java-cfenv/releases/tag/v3.0.0

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search