Commit 4fa076be by 刘宇峰

任务调度程序

1 parent c7a31e1f
...@@ -7,8 +7,11 @@ import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfigurat ...@@ -7,8 +7,11 @@ import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfigurat
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.client.RestTemplate;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.util.TimeZone; import java.util.TimeZone;
...@@ -35,4 +38,10 @@ public class Application { ...@@ -35,4 +38,10 @@ public class Application {
TimeZone.setDefault(getTimeZone(of("Asia/Shanghai"))); TimeZone.setDefault(getTimeZone(of("Asia/Shanghai")));
} }
@LoadBalanced
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
} }
...@@ -13,11 +13,11 @@ public class RestSimpleJobService { ...@@ -13,11 +13,11 @@ public class RestSimpleJobService {
public void simpleJob(String name) { public void simpleJob(String name) {
try { try {
log.info("do something for job"); Thread.sleep(15000);
Thread.sleep(10000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
log.info(name);
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!