This is an automated email from the ASF dual-hosted git repository.
wuweijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob.git
The following commit(s) were added to refs/heads/master by this push:
new 0b3a6eb99 Revise example (#2363)
0b3a6eb99 is described below
commit 0b3a6eb993ee1abcb8ae81efa6ccaeb9b494ea5c
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Nov 1 22:53:32 2023 +0800
Revise example (#2363)
* Revise example
* Revise example
---
ecosystem/tracing/rdb/pom.xml | 1 -
examples/elasticjob-example-java/pom.xml | 10 ++++++----
.../shardingsphere/elasticjob/example/JavaMain.java | 14 +++++++-------
.../example/job/dataflow/SpringDataflowJob.java | 6 +++---
.../elasticjob/example/job/simple/SpringSimpleJob.java | 8 ++++----
examples/elasticjob-example-spring/pom.xml | 10 ++++++----
examples/pom.xml | 18 +++++++++++-------
7 files changed, 37 insertions(+), 30 deletions(-)
diff --git a/ecosystem/tracing/rdb/pom.xml b/ecosystem/tracing/rdb/pom.xml
index 2dcc16378..840e367da 100644
--- a/ecosystem/tracing/rdb/pom.xml
+++ b/ecosystem/tracing/rdb/pom.xml
@@ -43,7 +43,6 @@
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
diff --git a/examples/elasticjob-example-java/pom.xml
b/examples/elasticjob-example-java/pom.xml
index 88190535a..b0cb73419 100644
--- a/examples/elasticjob-example-java/pom.xml
+++ b/examples/elasticjob-example-java/pom.xml
@@ -76,10 +76,7 @@
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-dbcp2</artifactId>
- </dependency>
+
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
@@ -88,5 +85,10 @@
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>com.zaxxer</groupId>
+ <artifactId>HikariCP</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git
a/examples/elasticjob-example-java/src/main/java/org/apache/shardingsphere/elasticjob/example/JavaMain.java
b/examples/elasticjob-example-java/src/main/java/org/apache/shardingsphere/elasticjob/example/JavaMain.java
index d5502cf2f..c559e8bb5 100644
---
a/examples/elasticjob-example-java/src/main/java/org/apache/shardingsphere/elasticjob/example/JavaMain.java
+++
b/examples/elasticjob-example-java/src/main/java/org/apache/shardingsphere/elasticjob/example/JavaMain.java
@@ -17,23 +17,23 @@
package org.apache.shardingsphere.elasticjob.example;
-import org.apache.commons.dbcp2.BasicDataSource;
+import com.zaxxer.hikari.HikariDataSource;
import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
+import org.apache.shardingsphere.elasticjob.bootstrap.type.OneOffJobBootstrap;
+import
org.apache.shardingsphere.elasticjob.bootstrap.type.ScheduleJobBootstrap;
import
org.apache.shardingsphere.elasticjob.dataflow.props.DataflowJobProperties;
import
org.apache.shardingsphere.elasticjob.error.handler.dingtalk.DingtalkPropertiesConstants;
import
org.apache.shardingsphere.elasticjob.error.handler.email.EmailPropertiesConstants;
import
org.apache.shardingsphere.elasticjob.error.handler.wechat.WechatPropertiesConstants;
import
org.apache.shardingsphere.elasticjob.example.job.dataflow.JavaDataflowJob;
-import org.apache.shardingsphere.elasticjob.http.props.HttpJobProperties;
-import org.apache.shardingsphere.elasticjob.bootstrap.type.OneOffJobBootstrap;
-import
org.apache.shardingsphere.elasticjob.bootstrap.type.ScheduleJobBootstrap;
import
org.apache.shardingsphere.elasticjob.example.job.simple.JavaOccurErrorJob;
import org.apache.shardingsphere.elasticjob.example.job.simple.JavaSimpleJob;
+import org.apache.shardingsphere.elasticjob.http.props.HttpJobProperties;
+import
org.apache.shardingsphere.elasticjob.kernel.tracing.config.TracingConfiguration;
import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
import
org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperConfiguration;
import
org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperRegistryCenter;
import org.apache.shardingsphere.elasticjob.script.props.ScriptJobProperties;
-import
org.apache.shardingsphere.elasticjob.kernel.tracing.config.TracingConfiguration;
import javax.sql.DataSource;
import java.io.IOException;
@@ -86,9 +86,9 @@ public final class JavaMain {
}
private static DataSource setUpEventTraceDataSource() {
- BasicDataSource result = new BasicDataSource();
+ HikariDataSource result = new HikariDataSource();
result.setDriverClassName(EVENT_RDB_STORAGE_DRIVER);
- result.setUrl(EVENT_RDB_STORAGE_URL);
+ result.setJdbcUrl(EVENT_RDB_STORAGE_URL);
result.setUsername(EVENT_RDB_STORAGE_USERNAME);
result.setPassword(EVENT_RDB_STORAGE_PASSWORD);
return result;
diff --git
a/examples/elasticjob-example-jobs/src/main/java/org/apache/shardingsphere/elasticjob/example/job/dataflow/SpringDataflowJob.java
b/examples/elasticjob-example-jobs/src/main/java/org/apache/shardingsphere/elasticjob/example/job/dataflow/SpringDataflowJob.java
index 9cc3e2c2c..32f332ebb 100644
---
a/examples/elasticjob-example-jobs/src/main/java/org/apache/shardingsphere/elasticjob/example/job/dataflow/SpringDataflowJob.java
+++
b/examples/elasticjob-example-jobs/src/main/java/org/apache/shardingsphere/elasticjob/example/job/dataflow/SpringDataflowJob.java
@@ -17,19 +17,19 @@
package org.apache.shardingsphere.elasticjob.example.job.dataflow;
-import
org.apache.shardingsphere.elasticjob.spi.executor.item.param.ShardingContext;
import org.apache.shardingsphere.elasticjob.dataflow.job.DataflowJob;
import org.apache.shardingsphere.elasticjob.example.fixture.entity.Foo;
import
org.apache.shardingsphere.elasticjob.example.fixture.repository.FooRepository;
+import
org.apache.shardingsphere.elasticjob.spi.executor.item.param.ShardingContext;
+import org.springframework.beans.factory.annotation.Autowired;
-import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
public class SpringDataflowJob implements DataflowJob<Foo> {
- @Resource
+ @Autowired
private FooRepository fooRepository;
@Override
diff --git
a/examples/elasticjob-example-jobs/src/main/java/org/apache/shardingsphere/elasticjob/example/job/simple/SpringSimpleJob.java
b/examples/elasticjob-example-jobs/src/main/java/org/apache/shardingsphere/elasticjob/example/job/simple/SpringSimpleJob.java
index 3f2e4ee18..4f5e794b0 100644
---
a/examples/elasticjob-example-jobs/src/main/java/org/apache/shardingsphere/elasticjob/example/job/simple/SpringSimpleJob.java
+++
b/examples/elasticjob-example-jobs/src/main/java/org/apache/shardingsphere/elasticjob/example/job/simple/SpringSimpleJob.java
@@ -17,19 +17,19 @@
package org.apache.shardingsphere.elasticjob.example.job.simple;
-import
org.apache.shardingsphere.elasticjob.spi.executor.item.param.ShardingContext;
-import org.apache.shardingsphere.elasticjob.simple.job.SimpleJob;
import org.apache.shardingsphere.elasticjob.example.fixture.entity.Foo;
import
org.apache.shardingsphere.elasticjob.example.fixture.repository.FooRepository;
+import org.apache.shardingsphere.elasticjob.simple.job.SimpleJob;
+import
org.apache.shardingsphere.elasticjob.spi.executor.item.param.ShardingContext;
+import org.springframework.beans.factory.annotation.Autowired;
-import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
public class SpringSimpleJob implements SimpleJob {
- @Resource
+ @Autowired
private FooRepository fooRepository;
@Override
diff --git a/examples/elasticjob-example-spring/pom.xml
b/examples/elasticjob-example-spring/pom.xml
index ca6fdf3b1..1ab4ffaa7 100644
--- a/examples/elasticjob-example-spring/pom.xml
+++ b/examples/elasticjob-example-spring/pom.xml
@@ -80,10 +80,7 @@
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-dbcp2</artifactId>
- </dependency>
+
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
@@ -92,5 +89,10 @@
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>com.zaxxer</groupId>
+ <artifactId>HikariCP</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git a/examples/pom.xml b/examples/pom.xml
index a919a8399..44330cc31 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -44,11 +44,12 @@
<slf4j.version>1.7.36</slf4j.version>
<logback.version>1.2.12</logback.version>
-
- <commons-dbcp2.version>2.10.0</commons-dbcp2.version>
+
<h2.version>2.2.224</h2.version>
<mysql-connector-java.version>8.0.31</mysql-connector-java.version>
+ <hikari-cp.version>4.0.3</hikari-cp.version>
+
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
<flatten-maven-plugin.version>1.2.5</flatten-maven-plugin.version>
</properties>
@@ -81,6 +82,7 @@
<artifactId>spring-context</artifactId>
<version>${springframework.version}</version>
</dependency>
+
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
@@ -101,11 +103,7 @@
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-dbcp2</artifactId>
- <version>${commons-dbcp2.version}</version>
- </dependency>
+
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
@@ -116,6 +114,12 @@
<artifactId>mysql-connector-j</artifactId>
<version>${mysql-connector-java.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>com.zaxxer</groupId>
+ <artifactId>HikariCP</artifactId>
+ <version>${hikari-cp.version}</version>
+ </dependency>
</dependencies>
</dependencyManagement>