issue-86 #102
@ -5,12 +5,16 @@ import core.entities.UserRole;
|
||||
import core.repositories.RoleRepository;
|
||||
import core.repositories.UserRepository;
|
||||
import core.services.PropertyService;
|
||||
import core.services.TaskScheduleService;
|
||||
import core.services.ntfy.TaskSchedulingService;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
public class DemoApplication{
|
||||
|
||||
public static void main(String[] args) {
|
||||
@ -18,19 +22,10 @@ public class DemoApplication{
|
||||
}
|
||||
|
||||
|
||||
/*@Bean
|
||||
public CommandLineRunner init(RoleRepository roleRepository, UserRepository userRepository, PropertyService propertyService) {
|
||||
@Bean
|
||||
public CommandLineRunner init() {
|
||||
return args -> {
|
||||
for (UserRole userRole : UserRole.values()) {
|
||||
if(!roleRepository.existsByName(userRole)) {
|
||||
roleRepository.save(new RoleEntity(userRole));
|
||||
}
|
||||
}
|
||||
|
||||
propertyService.init();
|
||||
|
||||
FirstUserObserver observer = new FirstUserObserver(userRepository);
|
||||
observer.start();
|
||||
TaskSchedulingService.scheduleTask();
|
||||
};
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
8
backend/src/main/java/core/services/ntfy/NtfyTask.java
Normal file
8
backend/src/main/java/core/services/ntfy/NtfyTask.java
Normal file
@ -0,0 +1,8 @@
|
||||
package core.services.ntfy;
|
||||
|
||||
public class NtfyTask implements Runnable{
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("A little Test");
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package core.services.ntfy;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
import org.springframework.scheduling.support.CronTrigger;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
public class TaskSchedulingService {
|
||||
|
||||
|
||||
public static void scheduleTask() {
|
||||
ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
|
||||
threadPoolTaskScheduler.initialize();
|
||||
threadPoolTaskScheduler.schedule(new NtfyTask(), new CronTrigger("0 0/1 * 1/1 * *"));
|
||||
}
|
||||
}
|
@ -27,6 +27,7 @@ spring.jpa.open-in-view=false
|
||||
|
||||
|
||||
|
||||
|
||||
# Spring Data Rest Setup
|
||||
spring.data.rest.base-path=/api
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user