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:
parent
59fc344730
commit
a0fd5f67a7
|
@ -1,12 +1,14 @@
|
||||||
package eu.dnetlib.repo.manager;
|
package eu.dnetlib.repo.manager;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
@SpringBootApplication
|
|
||||||
public class Application {
|
@SpringBootApplication
|
||||||
|
@EnableScheduling
|
||||||
public static void main(String[] args) {
|
public class Application {
|
||||||
SpringApplication.run(Application.class, args);
|
|
||||||
}
|
public static void main(String[] args) {
|
||||||
}
|
SpringApplication.run(Application.class, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -5,7 +5,6 @@ import eu.dnetlib.repo.manager.repository.PendingUserRoleRepository;
|
||||||
import eu.dnetlib.repo.manager.service.aai.registry.AaiRegistryService;
|
import eu.dnetlib.repo.manager.service.aai.registry.AaiRegistryService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -21,7 +20,6 @@ public class PendingUserRoleService {
|
||||||
this.aaiRegistryService = aaiRegistryService;
|
this.aaiRegistryService = aaiRegistryService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Scheduled(fixedRate = 3_600_000)
|
|
||||||
public void assignRoles() {
|
public void assignRoles() {
|
||||||
Iterable<PendingUserRole> roles = pendingUserRoleRepository.findAll();
|
Iterable<PendingUserRole> roles = pendingUserRoleRepository.findAll();
|
||||||
for (PendingUserRole role : roles) {
|
for (PendingUserRole role : roles) {
|
||||||
|
|
Loading…
Reference in New Issue