0

I want to use JDBC mysql with Spring cloud config server, but always failed, this is what I am doing:

Spring cloud version: Finchley.SR2

  1. In POM.xml

    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-server</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.tomcat</groupId>
                    <artifactId>tomcat-jdbc</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    
  2. Inside the application.config:

    spring.profiles.active= jdbc
    spring.datasource.url=jdbc:mysql://localhost:3306/config_db
    spring.datasource.username=root
    spring.datasource.password=12345
    spring.datasource.driver-class-name=com.mysql.jdbc.Driver
    spring.datasource.platform= mysql
    spring.cloud.config.server.jdbc.sql= SELECT `key`, `value` FROM `properties` WHERE `application`=? AND `profile`=? AND `label`=?;
    spring.cloud.config.server.jdbc.order=0
    spring.cloud.config.server.default-profile=production
    spring.cloud.config.server.default-label=latest

Finally, when I start server, I am getting below errors:

APPLICATION FAILED TO START
Description:
Invalid config server configuration.
Action:
If you are using the git profile, you need to set a Git URI in your configuration.  If you are using a native profile and have spring.cloud.config.server.bootstrap=true, you need to use a composite configuration.

I am not using git here, why the error is about git url?

p.campbell
  • 98,673
  • 67
  • 256
  • 322
user3006967
  • 3,291
  • 10
  • 47
  • 72

2 Answers2

0

I had the same issue when used MySQL. It seems to be an issue with MySQL JdbcTemplate (look here).

I switched to H2 to store configuration and it works.

I wonder if there any workaround to use MySQL?

Ronen
  • 807
  • 1
  • 13
  • 33
0

I got the same error when I attempt to remove the DataSourceAutoConfiguration.class on start up i.e.

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })

When I just used

@SpringBootApplication

everything worked as expected.

My reason for excluding the class was to stop the auto generation of a password on startup.

Dave
  • 577
  • 6
  • 25