Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit 1d25dee

Browse files
jvalkealilayaperumalg
authored andcommitted
Document adding mysql driver to a server
- As an temporary fix for this documentation issue, provide gradle and maven samples how to build a custom dataflow server adding mysql driver. These custom build files examples will produce same fatjar as project itself with an addition of mysql-connector-java-8.0.16.jar. - This lays groundwork to make dependency management more clear as there is a way too much manual configuration for dependencies and versions for custom gradle and maven builds. - Fixes #2489
1 parent 25f5dca commit 1d25dee

File tree

1 file changed

+170
-2
lines changed

1 file changed

+170
-2
lines changed

spring-cloud-dataflow-docs/src/main/asciidoc/configuration-local.adoc

Lines changed: 170 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,10 @@ NOTE: Due to licensing restrictions we're unable to bundle Oracle driver. You ne
160160

161161
==== Adding a Custom JDBC Driver
162162
To add a custom driver for the database (for example, Oracle), you should rebuild the Data Flow Server and add the dependency to the Maven `pom.xml` file.
163-
Since there is a Spring Cloud Data Flow Server for each target platform, you need to modify the appropriate maven `pom.xml` for each platform. There are tags in each GitHub repository for each server version.
163+
You need to modify the maven `pom.xml` of `spring-cloud-dataflow-server` module.
164+
There are GA release tags in GitHub repository, so you can switch to desired GA tags to add the drivers on the production-ready codebase.
164165

165-
To add a custom JDBC driver dependency for the local server implementation:
166+
To add a custom JDBC driver dependency for the Spring Cloud Data Flow server:
166167

167168
. Select the tag that corresponds to the version of the server you want to rebuild and clone the github repository.
168169
. Edit the spring-cloud-dataflow-server/pom.xml and, in the `dependencies` section, add the dependency for the database driver required. In the following example , an Oracle driver has been chosen:
@@ -196,6 +197,173 @@ spring:
196197
driver-class-name:org.postgresql.Driver
197198
----
198199

200+
[start=4]
201+
. Alternatively, you can build a custom Spring CLoud Data Flow server with your build files.
202+
Here are the examples of bundling MySQL driver using Gradle and Maven, which will result in the same jar as the original Spring Cloud Data Flow server version (example: `2.1.2.RELEASE`) with the addition of a mysql-connector-java-8.0.16.jar:
203+
204+
[source, groovy]
205+
.gradle
206+
----
207+
plugins {
208+
id 'org.springframework.boot' version '2.1.3.RELEASE'
209+
id 'java'
210+
}
211+
212+
ext {
213+
springCloudVersion = 'Greenwich.SR1'
214+
springCloudDataflowVersion = '2.1.2.RELEASE'
215+
springSecurityOauth2AutoconfigureVersion = '2.1.3.RELEASE'
216+
springSecurityOauth2Version = '2.3.4.RELEASE'
217+
kubernetesClientVersion = '4.0.4'
218+
mysqlJdbcDriverVersion = '8.0.16'
219+
}
220+
221+
apply plugin: 'io.spring.dependency-management'
222+
223+
group = 'com.example'
224+
version = '0.0.1-SNAPSHOT'
225+
sourceCompatibility = '1.8'
226+
227+
repositories {
228+
mavenCentral()
229+
maven { url "https://repo.springsource.org/libs-snapshot" }
230+
}
231+
232+
dependencyManagement {
233+
imports {
234+
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
235+
mavenBom "org.springframework.cloud:spring-cloud-dataflow-dependencies:${springCloudDataflowVersion}"
236+
}
237+
dependencies {
238+
dependency "org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:${springSecurityOauth2AutoconfigureVersion}"
239+
dependency "org.springframework.security.oauth:spring-security-oauth2:${springSecurityOauth2Version}"
240+
dependency "io.fabric8:kubernetes-client:${kubernetesClientVersion}"
241+
dependency("mysql:mysql-connector-java:${mysqlJdbcDriverVersion}") {
242+
exclude 'com.google.protobuf:protobuf-java'
243+
}
244+
}
245+
}
246+
247+
dependencies {
248+
implementation 'org.springframework.cloud:spring-cloud-starter-dataflow-server'
249+
runtime 'mysql:mysql-connector-java'
250+
testImplementation 'org.springframework.boot:spring-boot-starter-test'
251+
}
252+
----
253+
254+
255+
[source, xml]
256+
.maven
257+
----
258+
<?xml version="1.0" encoding="UTF-8"?>
259+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
260+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
261+
<modelVersion>4.0.0</modelVersion>
262+
<parent>
263+
<groupId>org.springframework.boot</groupId>
264+
<artifactId>spring-boot-starter-parent</artifactId>
265+
<version>2.1.3.RELEASE</version>
266+
<relativePath/>
267+
</parent>
268+
<groupId>com.example</groupId>
269+
<artifactId>custom-dataflow-server-maven</artifactId>
270+
<version>0.0.1-SNAPSHOT</version>
271+
<name>custom-dataflow-server</name>
272+
<description>Demo project for Spring Boot</description>
273+
274+
<properties>
275+
<java.version>1.8</java.version>
276+
<spring-cloud.version>Greenwich.SR1</spring-cloud.version>
277+
<spring-cloud-dataflow.version>2.1.2.RELEASE</spring-cloud-dataflow.version>
278+
<spring-security-oauth2.version>2.3.4.RELEASE</spring-security-oauth2.version>
279+
<mariadb.version>2.4.1</mariadb.version>
280+
<spring-security-oauth2-autoconfigure.version>2.1.3.RELEASE</spring-security-oauth2-autoconfigure.version>
281+
<kubernetes-client.version>4.0.4</kubernetes-client.version>
282+
<mysql-jdbc-driver.version>8.0.16</mysql-jdbc-driver.version>
283+
</properties>
284+
285+
<dependencies>
286+
<dependency>
287+
<groupId>org.springframework.cloud</groupId>
288+
<artifactId>spring-cloud-starter-dataflow-server</artifactId>
289+
</dependency>
290+
<dependency>
291+
<groupId>org.springframework.boot</groupId>
292+
<artifactId>spring-boot-starter-test</artifactId>
293+
<scope>test</scope>
294+
</dependency>
295+
<dependency>
296+
<groupId>org.springframework.security.oauth.boot</groupId>
297+
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
298+
<version>${spring-security-oauth2-autoconfigure.version}</version>
299+
</dependency>
300+
<dependency>
301+
<groupId>org.springframework.security.oauth</groupId>
302+
<artifactId>spring-security-oauth2</artifactId>
303+
<version>${spring-security-oauth2.version}</version>
304+
</dependency>
305+
<dependency>
306+
<groupId>io.fabric8</groupId>
307+
<artifactId>kubernetes-client</artifactId>
308+
<version>${kubernetes-client.version}</version>
309+
</dependency>
310+
<dependency>
311+
<groupId>mysql</groupId>
312+
<artifactId>mysql-connector-java</artifactId>
313+
</dependency>
314+
</dependencies>
315+
316+
<dependencyManagement>
317+
<dependencies>
318+
<dependency>
319+
<groupId>org.springframework.cloud</groupId>
320+
<artifactId>spring-cloud-dependencies</artifactId>
321+
<version>${spring-cloud.version}</version>
322+
<type>pom</type>
323+
<scope>import</scope>
324+
</dependency>
325+
<dependency>
326+
<groupId>org.springframework.cloud</groupId>
327+
<artifactId>spring-cloud-dataflow-dependencies</artifactId>
328+
<version>${spring-cloud-dataflow.version}</version>
329+
<type>pom</type>
330+
<scope>import</scope>
331+
</dependency>
332+
<dependency>
333+
<groupId>mysql</groupId>
334+
<artifactId>mysql-connector-java</artifactId>
335+
<version>${mysql-jdbc-driver.version}</version>
336+
<exclusions>
337+
<exclusion>
338+
<groupId>com.google.protobuf</groupId>
339+
<artifactId>protobuf-java</artifactId>
340+
</exclusion>
341+
</exclusions>
342+
</dependency>
343+
</dependencies>
344+
</dependencyManagement>
345+
346+
<build>
347+
<plugins>
348+
<plugin>
349+
<groupId>org.springframework.boot</groupId>
350+
<artifactId>spring-boot-maven-plugin</artifactId>
351+
</plugin>
352+
</plugins>
353+
</build>
354+
<repositories>
355+
<repository>
356+
<id>spring-snapshots</id>
357+
<name>Spring Snapshots</name>
358+
<url>http://repo.spring.io/libs-snapshot</url>
359+
<snapshots>
360+
<enabled>true</enabled>
361+
</snapshots>
362+
</repository>
363+
</repositories>
364+
</project>
365+
----
366+
199367
[[configuration-local-deployer]]
200368
=== Deployer Properties
201369
You can use the following configuration properties of the https://github.com/spring-cloud/spring-cloud-deployer-local[Local deployer] to customize how Streams and Tasks are deployed.

0 commit comments

Comments
 (0)