From 9fc1e6b9e00b6e6a99b1a19c650af5d60ca93cad Mon Sep 17 00:00:00 2001 From: javahongxi Date: Thu, 5 Dec 2019 19:47:41 +0800 Subject: [PATCH] optimise --- whatsmars-spring-data/pom.xml | 25 +++++++++++++++++++ .../whatsmars/spring/data/Application.java | 4 +++ .../spring/data/config/MogoConfiguration.java | 9 ------- .../spring/data/service/DataService.java | 11 +++++++- .../src/main/resources/log4j2.xml | 25 +++++++++++++++++++ 5 files changed, 64 insertions(+), 10 deletions(-) delete mode 100644 whatsmars-spring-data/src/main/java/org/hongxi/whatsmars/spring/data/config/MogoConfiguration.java create mode 100644 whatsmars-spring-data/src/main/resources/log4j2.xml diff --git a/whatsmars-spring-data/pom.xml b/whatsmars-spring-data/pom.xml index 213ef7b6..8983f8a7 100644 --- a/whatsmars-spring-data/pom.xml +++ b/whatsmars-spring-data/pom.xml @@ -16,6 +16,14 @@ org.springframework.data spring-data-redis + + redis.clients + jedis + + + org.apache.commons + commons-pool2 + org.springframework.data spring-data-elasticsearch @@ -29,6 +37,23 @@ org.hongxi whatsmars-common + + + org.apache.logging.log4j + log4j-api + + + org.apache.logging.log4j + log4j-core + + + org.apache.logging.log4j + log4j-slf4j-impl + + + log4j + log4j + diff --git a/whatsmars-spring-data/src/main/java/org/hongxi/whatsmars/spring/data/Application.java b/whatsmars-spring-data/src/main/java/org/hongxi/whatsmars/spring/data/Application.java index 07b58686..98343a8e 100644 --- a/whatsmars-spring-data/src/main/java/org/hongxi/whatsmars/spring/data/Application.java +++ b/whatsmars-spring-data/src/main/java/org/hongxi/whatsmars/spring/data/Application.java @@ -2,7 +2,11 @@ package org.hongxi.whatsmars.spring.data; import org.hongxi.whatsmars.common.profile.ProfileUtils; import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; +@ImportResource("classpath:spring-*.xml") +@Configuration public class Application { public static void main(String[] args) { diff --git a/whatsmars-spring-data/src/main/java/org/hongxi/whatsmars/spring/data/config/MogoConfiguration.java b/whatsmars-spring-data/src/main/java/org/hongxi/whatsmars/spring/data/config/MogoConfiguration.java deleted file mode 100644 index fd4591ee..00000000 --- a/whatsmars-spring-data/src/main/java/org/hongxi/whatsmars/spring/data/config/MogoConfiguration.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.hongxi.whatsmars.spring.data.config; - -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.ImportResource; - -@Configuration -@ImportResource("classpath:spring-mongo.xml") -public class MogoConfiguration { -} diff --git a/whatsmars-spring-data/src/main/java/org/hongxi/whatsmars/spring/data/service/DataService.java b/whatsmars-spring-data/src/main/java/org/hongxi/whatsmars/spring/data/service/DataService.java index 4d118cc3..57200124 100644 --- a/whatsmars-spring-data/src/main/java/org/hongxi/whatsmars/spring/data/service/DataService.java +++ b/whatsmars-spring-data/src/main/java/org/hongxi/whatsmars/spring/data/service/DataService.java @@ -2,6 +2,7 @@ package org.hongxi.whatsmars.spring.data.service; import org.elasticsearch.client.transport.TransportClient; import org.hongxi.whatsmars.spring.data.repository.CustomerRepository; +import org.springframework.beans.factory.InitializingBean; import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; @@ -9,7 +10,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; @Service -public class DataService { +public class DataService implements InitializingBean { @Resource private RedisTemplate redisTemplate; @@ -19,4 +20,12 @@ public class DataService { private MongoTemplate mongoTemplate; @Resource private CustomerRepository customerRepository; + + @Override + public void afterPropertiesSet() throws Exception { + System.out.println(redisTemplate); + System.out.println(transportClient); + System.out.println(mongoTemplate); + System.out.println(customerRepository); + } } diff --git a/whatsmars-spring-data/src/main/resources/log4j2.xml b/whatsmars-spring-data/src/main/resources/log4j2.xml new file mode 100644 index 00000000..6238a684 --- /dev/null +++ b/whatsmars-spring-data/src/main/resources/log4j2.xml @@ -0,0 +1,25 @@ + + + + + /data/logs/whatsmars-spring-data + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- GitLab