Commit 866d6beb authored by Node- 门 忠鑫's avatar Node- 门 忠鑫

# 添加@lazy注解

parent c5c22976
...@@ -2,6 +2,7 @@ package cn.quantgroup.tech.enoch.agent; ...@@ -2,6 +2,7 @@ package cn.quantgroup.tech.enoch.agent;
import cn.quantgroup.tech.enoch.agent.report.IReportService; import cn.quantgroup.tech.enoch.agent.report.IReportService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -10,6 +11,7 @@ import org.springframework.stereotype.Component; ...@@ -10,6 +11,7 @@ import org.springframework.stereotype.Component;
* @author: amen * @author: amen
* @date: 2019-02-26 * @date: 2019-02-26
*/ */
@Lazy
@Component @Component
@EnableScheduling @EnableScheduling
public class AgentReportTask { public class AgentReportTask {
...@@ -32,4 +34,5 @@ public class AgentReportTask { ...@@ -32,4 +34,5 @@ public class AgentReportTask {
public void report() { public void report() {
reportService.report(); reportService.report();
} }
} }
\ No newline at end of file
...@@ -2,11 +2,11 @@ package cn.quantgroup.tech.enoch.agent.configuration; ...@@ -2,11 +2,11 @@ package cn.quantgroup.tech.enoch.agent.configuration;
import cn.quantgroup.tech.enoch.agent.AgentReportTask; import cn.quantgroup.tech.enoch.agent.AgentReportTask;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.kafka.clients.producer.ProducerConfig; import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.common.serialization.StringSerializer; import org.apache.kafka.common.serialization.StringSerializer;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
...@@ -17,6 +17,7 @@ import org.springframework.kafka.core.ProducerFactory; ...@@ -17,6 +17,7 @@ import org.springframework.kafka.core.ProducerFactory;
import org.springframework.scheduling.annotation.SchedulingConfigurer; import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar; import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import java.math.BigDecimal;
import java.util.HashMap; import java.util.HashMap;
import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ScheduledThreadPoolExecutor;
...@@ -26,13 +27,17 @@ import java.util.concurrent.ScheduledThreadPoolExecutor; ...@@ -26,13 +27,17 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
*/ */
@Slf4j @Slf4j
@Configuration @Configuration
@ComponentScan(basePackageClasses = {AgentReportTask.class}) @ComponentScan(basePackageClasses = AgentReportTask.class)
@EnableConfigurationProperties(EnochAgentProperties.class) @EnableConfigurationProperties(EnochAgentProperties.class)
@ConditionalOnProperty(prefix = "tech.enoch", name = "enabled", havingValue = "true")
public class EnochAgentAutoConfiguration { public class EnochAgentAutoConfiguration {
@Autowired @Autowired
private EnochAgentProperties enochAgentProperties; private EnochAgentProperties enochAgentProperties;
@Autowired
private AgentReportTask agentReportTask;
@Bean @Bean
public ProducerFactory<String, String> producerFactory() { public ProducerFactory<String, String> producerFactory() {
HashMap<String, Object> config = new HashMap<>(16); HashMap<String, Object> config = new HashMap<>(16);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment