Skip to content

Commit

Permalink
upgrade jar version
Browse files Browse the repository at this point in the history
  • Loading branch information
ponfee committed Mar 9, 2024
1 parent c73afab commit 4c16d97
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 52 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ disjob # 主项目①
- [管理后台—disjob-admin](disjob-admin/pom.xml)
- [范例项目—disjob-samples](disjob-samples/pom.xml)

2. 启动以下各应用组成分布式调度集群
2. 启动以下各应用(执行java main方法)组成分布式调度集群

> 已配置不同的端口可同时启动。可以在开发工具中运行Java类,也可通过`java -jar`命令运行构建好的jar包。
Expand Down
2 changes: 1 addition & 1 deletion disjob-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<kaptcha.version>2.3.3</kaptcha.version>
<pagehelper-spring-boot-starter.version>1.4.7</pagehelper-spring-boot-starter.version>
<fastjson.version>1.2.83</fastjson.version>
<oshi-core.version>6.4.11</oshi-core.version>
<oshi-core.version>6.4.13</oshi-core.version>
<commons-io.version>2.15.1</commons-io.version>
<poi-ooxml.version>5.2.5</poi-ooxml.version>
<velocity-engine-core.version>2.3</velocity-engine-core.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,24 @@
* import java.util.*
* def uuid = UUID.randomUUID().toString()
* savepoint.save(new Date().toString() + ": " + uuid)
* return "execute at: " + new Date() + ", " + jobHandler.toString()
* return "taskId: " + executingTask.getTaskId() + ", execute at: " + new Date() + ", " + jobHandler.toString()
* }</pre>
*
* @author Ponfee
*/
public class GroovyJobHandler extends JobHandler {

public static final String JOB_HANDLER = "jobHandler";
public static final String EXECUTING_TASK = "executingTask";
public static final String SAVEPOINT = "savepoint";

@Override
public ExecuteResult execute(ExecutingTask executingTask, Savepoint savepoint) throws Exception {
String scriptText = executingTask.getTaskParam();
Map<String, Object> params = ImmutableMap.of(
"jobHandler", this,
"executingTask", executingTask,
"savepoint", savepoint
JOB_HANDLER, this,
EXECUTING_TASK, executingTask,
SAVEPOINT, savepoint
);

Object result = GroovyUtils.Evaluator.SCRIPT.eval(scriptText, params);
Expand Down
2 changes: 1 addition & 1 deletion disjob-registry/disjob-registry-nacos/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
<version>2.3.0</version>
<version>2.3.1</version>
</dependency>

<dependency>
Expand Down
2 changes: 1 addition & 1 deletion disjob-samples/disjob-samples-frameless-worker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web</artifactId>
<version>4.4.5</version>
<version>4.5.4</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
public class WorkerFramelessMain {

static {
// for log4j log file dir
// for log4j2 log file name
System.setProperty("app.name", "frameless-worker");
JobHandlerParser.init();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
public class MergedApplication extends AbstractSamplesApplication {

static {
// for log4j log file dir
// for log4j2 log file name
System.setProperty("app.name", "springboot-merged");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
public class SupervisorApplication extends AbstractSamplesApplication {

static {
// for log4j log file dir
// for log4j2 log file name
System.setProperty("app.name", "springboot-supervisor");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public class WorkerApplication extends AbstractSamplesApplication {

static {
// for log4j log file dir
// for log4j2 log file name
System.setProperty("app.name", "springboot-worker");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,45 +114,6 @@ public abstract class AbstractDataSourceConfig implements ApplicationContextAwar
this.environment = environment;
}

/**
* 使用该方式时,基于注解方式的事务不生效
*/
@Override
public void postProcessBeanFactory(@NonNull ConfigurableListableBeanFactory listableBeanFactory) throws BeansException {
// -------------------------data source
DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) listableBeanFactory;
DataSource dataSource = DataSourceBuilder.create()
//.type(com.zaxxer.hikari.HikariDataSource.class)
.build();
Binder binder = Binder.get(environment);
binder.bind(databaseName + ".datasource", Bindable.ofInstance(dataSource));
beanFactory.registerSingleton(databaseName + DATA_SOURCE_NAME_SUFFIX, dataSource);

// -------------------------register to spring as singleton bean
SqlSessionFactory sqlSessionFactory;
try {
sqlSessionFactory = createSqlSessionFactory(dataSource);
} catch (Exception e) {
throw new BeanInstantiationException(SqlSessionFactory.class, "Create mybatis SqlSessionFactory error.", e);
}
beanFactory.registerSingleton(databaseName + SQL_SESSION_FACTORY_NAME_SUFFIX, sqlSessionFactory);
beanFactory.registerSingleton(databaseName + SQL_SESSION_TEMPLATE_NAME_SUFFIX, new SqlSessionTemplate(sqlSessionFactory));
beanFactory.registerSingleton(databaseName + JDBC_TEMPLATE_NAME_SUFFIX, new JdbcTemplate(dataSource));
PlatformTransactionManager transactionManager = new DataSourceTransactionManager(dataSource);
beanFactory.registerSingleton(databaseName + TX_MANAGER_NAME_SUFFIX, transactionManager);
beanFactory.registerSingleton(databaseName + TX_TEMPLATE_NAME_SUFFIX, new TransactionTemplate(transactionManager));

// -------------------------mybatis mapper scanner
MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
mapperScannerConfigurer.setBasePackage(this.getClass().getPackage().getName() + ".mapper");
mapperScannerConfigurer.setSqlSessionTemplateBeanName(databaseName + SQL_SESSION_TEMPLATE_NAME_SUFFIX);
mapperScannerConfigurer.setBeanName(databaseName + MAPPER_SCANNER_CONFIGURER_NAME_SUFFIX);
mapperScannerConfigurer.postProcessBeanDefinitionRegistry(beanFactory);
mapperScannerConfigurer.setProcessPropertyPlaceHolders(true);
mapperScannerConfigurer.setApplicationContext(applicationContext);
beanFactory.registerSingleton(databaseName + MAPPER_SCANNER_CONFIGURER_NAME_SUFFIX, mapperScannerConfigurer);
}

/**
* 使用该方式时,基于注解方式的事务不生效
* 要加`@EnableTransactionManagement`才能使事务生效
Expand Down Expand Up @@ -220,6 +181,45 @@ public abstract class AbstractDataSourceConfig implements ApplicationContextAwar
//registry.registerBeanDefinition(ProxyTransactionManagementConfiguration.class.getName(), new RootBeanDefinition(ProxyTransactionManagementConfiguration.class));
}

/**
* 使用该方式时,基于注解方式的事务不生效
*/
@Override
public void postProcessBeanFactory(@NonNull ConfigurableListableBeanFactory listableBeanFactory) throws BeansException {
// -------------------------data source
DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) listableBeanFactory;
DataSource dataSource = DataSourceBuilder.create()
//.type(com.zaxxer.hikari.HikariDataSource.class)
.build();
Binder binder = Binder.get(environment);
binder.bind(databaseName + ".datasource", Bindable.ofInstance(dataSource));
beanFactory.registerSingleton(databaseName + DATA_SOURCE_NAME_SUFFIX, dataSource);

// -------------------------register to spring as singleton bean
SqlSessionFactory sqlSessionFactory;
try {
sqlSessionFactory = createSqlSessionFactory(dataSource);
} catch (Exception e) {
throw new BeanInstantiationException(SqlSessionFactory.class, "Create mybatis SqlSessionFactory error.", e);
}
beanFactory.registerSingleton(databaseName + SQL_SESSION_FACTORY_NAME_SUFFIX, sqlSessionFactory);
beanFactory.registerSingleton(databaseName + SQL_SESSION_TEMPLATE_NAME_SUFFIX, new SqlSessionTemplate(sqlSessionFactory));
beanFactory.registerSingleton(databaseName + JDBC_TEMPLATE_NAME_SUFFIX, new JdbcTemplate(dataSource));
PlatformTransactionManager transactionManager = new DataSourceTransactionManager(dataSource);
beanFactory.registerSingleton(databaseName + TX_MANAGER_NAME_SUFFIX, transactionManager);
beanFactory.registerSingleton(databaseName + TX_TEMPLATE_NAME_SUFFIX, new TransactionTemplate(transactionManager));

// -------------------------mybatis mapper scanner
MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
mapperScannerConfigurer.setBasePackage(this.getClass().getPackage().getName() + ".mapper");
mapperScannerConfigurer.setSqlSessionTemplateBeanName(databaseName + SQL_SESSION_TEMPLATE_NAME_SUFFIX);
mapperScannerConfigurer.setBeanName(databaseName + MAPPER_SCANNER_CONFIGURER_NAME_SUFFIX);
mapperScannerConfigurer.postProcessBeanDefinitionRegistry(beanFactory);
mapperScannerConfigurer.setProcessPropertyPlaceHolders(true);
mapperScannerConfigurer.setApplicationContext(applicationContext);
beanFactory.registerSingleton(databaseName + MAPPER_SCANNER_CONFIGURER_NAME_SUFFIX, mapperScannerConfigurer);
}

private SqlSessionFactory createSqlSessionFactory(DataSource dataSource) throws Exception {
SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
factoryBean.setDataSource(dataSource);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<mariaDB4j.version>2.5.3</mariaDB4j.version>
<embedded-redis.version>1.4</embedded-redis.version>
<graphviz-java.version>0.18.1</graphviz-java.version>
<testcontainers.version>1.19.5</testcontainers.version>
<testcontainers.version>1.19.7</testcontainers.version>

<!-- spring-boot-dependencies [type=pom, scope=import]方式,无法自动引入plugin依赖版本 -->
<maven-clean-plugin.version>3.2.0</maven-clean-plugin.version>
Expand Down

0 comments on commit 4c16d97

Please sign in to comment.