Skip to content

Commit

Permalink
add bintray, enhance readme.md, remove fat jar
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeny Karpov committed Nov 23, 2018
1 parent c1a16a0 commit e49b38b
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 8 deletions.
58 changes: 57 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,60 @@ property section.
By default each declared datasource is created as HikariCP datasource. If different
`javax.sql.DataSource` implementation is needed, then own bean implementation
of the interface `io.ankburov.spring.balancing.datasource.factory.DataSourceFactory`
should be used.
should be used.

# Download
## Gradle
### Bintray
```groovy
repositories {
jcenter()
}
dependencies {
compile "io.ankburov:spring-balancing-datasource<version>"
}
```

### JitPack
```groovy
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
compile "com.github.AnkBurov:spring-balancing-datasource:<version>"
}
```

# Usage

Add `@EnableBalancingDataSource` annotation to your Spring boot configuration:
```java
@Configuration
@EnableBalancingDataSource
public class JdbcAdapterConfiguration {}
```

Define minimal configuration in properties. All available properties are defined in `BalancingDataSourceConfiguration`
or in generated `spring-configuration-metadata.json`

`application.yaml` example:
```yaml
spring:
balancing-dataSources-config:
data-sources:
main_oracle:
url: jdbc:oracle:thin:@localhost:1521:xe
username: system
password: oracle
name: whatever
standby_oracle:
url: jdbc:oracle:thin:@localhost:1525:xe
username: system
password: oracle
name: jdbc-adapter-local-test
data-sources-order: "main_oracle,standby_oracle"
```
After that all JDBC connections from `dataSource` bean with an implementation as `BalancingDataSource` will be balanced across
defined datasources according to used `BalancingStrategy` - in failover manner or load-balancing one.
38 changes: 31 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath "org.junit.platform:junit-platform-gradle-plugin:1.2.0"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4"
}
}

apply plugin: "java"
apply plugin: "groovy"
apply plugin: "org.junit.platform.gradle.plugin"
apply plugin: "maven"
apply plugin: "maven-publish"
apply plugin: 'com.jfrog.bintray'


group 'io.ankburov'
version '1.0'
version '1.0.4'

sourceCompatibility = 1.8

Expand Down Expand Up @@ -43,16 +45,38 @@ dependencies {

compileJava.dependsOn(processResources)

jar {
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
}

jar.dependsOn(sourcesJar)

publishing {
publications {
maven(MavenPublication) {
toMaven(MavenPublication) {
groupId project.group
artifactId project.name
version project.version
from components.java

artifact sourcesJar {
classifier "sources"
}
}
}
}

bintray {
user = project.hasProperty("user") ? project.property("user") : "fake"
key = project.hasProperty("key") ? project.property("key") : "fake"

publications = ['toMaven']
publish = true

pkg {
repo = 'maven'
name = rootProject.name
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/AnkBurov/spring-balancing-datasource.git'
}
}

0 comments on commit e49b38b

Please sign in to comment.