İlk*_*nel 5 spring-data-jpa shedlock
我将 ShedLock 添加到我的项目中,以防止预定作业重复执行一次。我将其配置如下,但我得到了
“org.postgresql.util.PSQLException:错误:关系“shedlock”不存在”错误。
这是lockProviderBean:
@Bean
public LockProvider lockProvider(DataSource dataSource) {
return new JdbcTemplateLockProvider(
JdbcTemplateLockProvider.Configuration.builder()
.withJdbcTemplate(new JdbcTemplate(dataSource))
.usingDbTime()
.build()
);
}
Run Code Online (Sandbox Code Playgroud)
这是预定的工作:
@Scheduled(cron = "${cronProperty:0 00 23 * * *}")
@SchedulerLock(name = "schedulerLockName")
public void scheduledJob() {
..............
}
Run Code Online (Sandbox Code Playgroud)
我将这些符号添加到包含 schduledJob 方法的类中:
@EnableScheduling
@Component
@Configuration
@EnableSchedulerLock(defaultLockAtMostFor = "2m")
Run Code Online (Sandbox Code Playgroud)
我正在使用 Spring Data 进行数据库操作并使用这些属性:
spring.datasource.url = jdbc:postgresql://ip:port/databaseName?currentSchema=schemeName
spring.datasource.driver-class-name = org.postgresql.Driver
spring.jpa.database = postgresql
spring.datasource.platform = postgresql
spring.datasource.hikari.maximum-pool-size=5
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.datasource.username = username
spring.datasource.password = password
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5151 次 |
| 最近记录: |