Fix the "NoSuchBeanDefinitionException: No bean named 'transactionManager' available", when trying to run the scheduled task -during initialization- for assigning pending user roles.

This commit is contained in:
Lampros Smyrnaios 2023-03-08 13:57:29 +02:00
parent 59fc344730
commit a0fd5f67a7
3 changed files with 34 additions and 14 deletions

View File

@ -1,12 +1,14 @@
package eu.dnetlib.repo.manager;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
package eu.dnetlib.repo.manager;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableScheduling
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@ -0,0 +1,20 @@
package eu.dnetlib.repo.manager.components;
import eu.dnetlib.repo.manager.service.PendingUserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class ScheduledTasks {
@Autowired
PendingUserRoleService pendingUserRoleService;
@Scheduled(fixedRate = 3_600_000)
public void assignPendingRoles() {
pendingUserRoleService.assignRoles();
}
}

View File

@ -5,7 +5,6 @@ import eu.dnetlib.repo.manager.repository.PendingUserRoleRepository;
import eu.dnetlib.repo.manager.service.aai.registry.AaiRegistryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
@Service
@ -21,7 +20,6 @@ public class PendingUserRoleService {
this.aaiRegistryService = aaiRegistryService;
}
@Scheduled(fixedRate = 3_600_000)
public void assignRoles() {
Iterable<PendingUserRole> roles = pendingUserRoleRepository.findAll();
for (PendingUserRole role : roles) {