yonge 5 年之前
父节点
当前提交
099389104b

+ 14 - 14
mec-auth/mec-auth-server/pom.xml

@@ -33,7 +33,7 @@
 			<groupId>org.springframework.cloud</groupId>
 			<artifactId>spring-cloud-starter-security</artifactId>
 		</dependency>
-		
+
 		<dependency>
 			<groupId>org.springframework.cloud</groupId>
 			<artifactId>spring-cloud-sleuth-zipkin</artifactId>
@@ -70,19 +70,19 @@
 			<artifactId>kaptcha</artifactId>
 			<version>2.3.2</version>
 		</dependency>
-		
-        <dependency>
-            <groupId>com.ym</groupId>
-            <artifactId>mec-client-api</artifactId>
-        </dependency>
-
-			<dependency>
-				<groupId>org.apache.commons</groupId>
-				<artifactId>commons-pool2</artifactId>
-			</dependency>
-
-    </dependencies>
-	
+
+		<dependency>
+			<groupId>com.ym</groupId>
+			<artifactId>mec-client-api</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.commons</groupId>
+			<artifactId>commons-pool2</artifactId>
+		</dependency>
+
+	</dependencies>
+
 	<build>
 		<plugins>
 			<plugin>

+ 2 - 2
mec-auth/mec-auth-server/src/main/resources/application.yml

@@ -41,7 +41,7 @@ spring:
     database: 0
     #连接超时时间(毫秒)
     timeout: 10000
-    lettuce:
+    jedis:
       pool:
         #连接池最大连接数(使用负值表示没有限制)
         max-active: 10
@@ -50,7 +50,7 @@ spring:
         #连接池中的最大空闲连接
         max-idle: 10
         #连接池中的最小空闲连接
-        min-idle: 0
+        min-idle: 1
 
 mybatis:
     mapperLocations: classpath:config/mybatis/*.xml

+ 13 - 1
mec-common/common-core/pom.xml

@@ -26,6 +26,12 @@
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter-data-redis</artifactId>
+			<exclusions>
+				<exclusion>
+					<groupId>io.lettuce</groupId>
+					<artifactId>lettuce-core</artifactId>
+				</exclusion>
+			</exclusions>
 		</dependency>
 		<!-- Redis缓存整合结束 -->
 
@@ -38,16 +44,22 @@
 			<groupId>org.springframework.cloud</groupId>
 			<artifactId>spring-cloud-starter-openfeign</artifactId>
 		</dependency>
+		
 		<dependency>
 			<groupId>com.ym</groupId>
 			<artifactId>mec-thirdparty</artifactId>
 		</dependency>
+		
+		<dependency>
+			<groupId>redis.clients</groupId>
+			<artifactId>jedis</artifactId>
+		</dependency>
+		
 		<dependency>
 			<groupId>org.springframework.security.oauth</groupId>
 			<artifactId>spring-security-oauth2</artifactId>
 			<version>2.2.1.RELEASE</version>
 		</dependency>
 
-
 	</dependencies>
 </project>

+ 54 - 0
mec-common/common-core/src/main/java/com/ym/mec/common/redis/config/RedisConfig.java

@@ -0,0 +1,54 @@
+package com.ym.mec.common.redis.config;
+
+import java.io.Serializable;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.connection.RedisPassword;
+import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
+import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+@Configuration
+public class RedisConfig {
+
+	@Value("${spring.redis.host}")
+	private String host;
+	
+	@Value("${spring.redis.port}")
+	private int port;
+	
+	@Value("${spring.redis.password}")
+	private String password;
+	
+	@Value("${spring.redis.database}")
+	private int database;
+
+	@Bean
+	public RedisConnectionFactory jedisConnectionFactory() {
+		RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
+		config.setHostName(host);
+		config.setPort(port);
+		config.setPassword(RedisPassword.of(password));
+		config.setDatabase(database);
+
+		JedisConnectionFactory factory = new JedisConnectionFactory(config);
+		return factory;
+	}
+
+	@Bean
+	public RedisTemplate<String, Serializable> redisTemplate(JedisConnectionFactory connectionFactory) {
+		RedisTemplate<String, Serializable> redisTemplate = new RedisTemplate<>();
+		redisTemplate.setKeySerializer(new StringRedisSerializer());
+		redisTemplate.setHashKeySerializer(new StringRedisSerializer());
+		redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());
+		redisTemplate.setHashValueSerializer(new JdkSerializationRedisSerializer());
+		redisTemplate.setConnectionFactory(jedisConnectionFactory());
+		return redisTemplate;
+	}
+
+}

+ 0 - 68
mec-common/common-core/src/main/java/com/ym/mec/common/redis/config/RedisTemplateConfig.java

@@ -1,68 +0,0 @@
-package com.ym.mec.common.redis.config;
-
-import org.springframework.boot.autoconfigure.AutoConfigureBefore;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
-import org.springframework.cache.annotation.EnableCaching;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.data.redis.connection.RedisConnectionFactory;
-import org.springframework.data.redis.core.HashOperations;
-import org.springframework.data.redis.core.ListOperations;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.data.redis.core.SetOperations;
-import org.springframework.data.redis.core.ValueOperations;
-import org.springframework.data.redis.core.ZSetOperations;
-import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
-import org.springframework.data.redis.serializer.StringRedisSerializer;
-
-/**
- * Redis 配置类
- */
-@EnableCaching
-@Configuration
-@AutoConfigureBefore(RedisAutoConfiguration.class)
-public class RedisTemplateConfig {
-
-	@Bean
-	@ConditionalOnMissingBean(name="redisTemplate")
-	public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
-		RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
-		redisTemplate.setKeySerializer(new StringRedisSerializer());
-		redisTemplate.setHashKeySerializer(new StringRedisSerializer());
-		redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());
-		redisTemplate.setHashValueSerializer(new JdkSerializationRedisSerializer());
-		redisTemplate.setConnectionFactory(redisConnectionFactory);
-		return redisTemplate;
-	}
-
-	@Bean
-	@ConditionalOnMissingBean(name="hashOperations")
-	public HashOperations<String, String, Object> hashOperations(RedisTemplate<String, Object> redisTemplate) {
-		return redisTemplate.opsForHash();
-	}
-
-	@Bean
-	@ConditionalOnMissingBean(name="valueOperations")
-	public ValueOperations<String, String> valueOperations(RedisTemplate<String, String> redisTemplate) {
-		return redisTemplate.opsForValue();
-	}
-
-	@Bean
-	@ConditionalOnMissingBean(name="listOperations")
-	public ListOperations<String, Object> listOperations(RedisTemplate<String, Object> redisTemplate) {
-		return redisTemplate.opsForList();
-	}
-
-	@Bean
-	@ConditionalOnMissingBean(name="setOperations")
-	public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) {
-		return redisTemplate.opsForSet();
-	}
-
-	@Bean
-	@ConditionalOnMissingBean(name="zSetOperations")
-	public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) {
-		return redisTemplate.opsForZSet();
-	}
-}

+ 0 - 12
mec-student/src/main/java/com/ym/mec/student/StudentApplication.java

@@ -1,21 +1,17 @@
 package com.ym.mec.student;
 
 import org.mybatis.spring.annotation.MapperScan;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.client.loadbalancer.LoadBalanced;
 import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.web.client.RestTemplate;
 
 import com.spring4all.swagger.EnableSwagger2Doc;
-import com.ym.mec.common.redis.service.RedisCache;
 
 @SpringBootApplication
 @EnableDiscoveryClient
@@ -26,9 +22,6 @@ import com.ym.mec.common.redis.service.RedisCache;
 @EnableSwagger2Doc
 public class StudentApplication {
 
-	@Autowired
-	private RedisTemplate<String, Object> redisTemplate;
-
 	public static void main(String[] args) {
 		SpringApplication.run(StudentApplication.class, args);
 	}
@@ -39,9 +32,4 @@ public class StudentApplication {
 		return new RestTemplate();
 	}
 
-	@Bean
-	@ConditionalOnBean(RedisTemplate.class)
-	public RedisCache<String, Object> redisCache() {
-		return new RedisCache<String, Object>(redisTemplate);
-	}
 }

+ 3 - 13
mec-teacher/src/main/java/com/ym/mec/teacher/TeacherApplication.java

@@ -1,21 +1,18 @@
 package com.ym.mec.teacher;
 
-import com.spring4all.swagger.EnableSwagger2Doc;
-import com.ym.mec.common.redis.service.RedisCache;
 import org.mybatis.spring.annotation.MapperScan;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.client.loadbalancer.LoadBalanced;
 import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.web.client.RestTemplate;
 
+import com.spring4all.swagger.EnableSwagger2Doc;
+
 @SpringBootApplication
 @EnableDiscoveryClient
 @EnableFeignClients("com.ym.mec")
@@ -24,22 +21,15 @@ import org.springframework.web.client.RestTemplate;
 @Configuration
 @EnableSwagger2Doc
 public class TeacherApplication {
+	
 	public static void main(String[] args) {
 		SpringApplication.run(TeacherApplication.class, args);
 	}
 
-	@Autowired
-	private RedisTemplate<String, Object> redisTemplate;
-
 	@Bean
 	@LoadBalanced
 	public RestTemplate restTemplate() {
 		return new RestTemplate();
 	}
 
-	@Bean
-	@ConditionalOnBean(RedisTemplate.class)
-	public RedisCache<String, Object> redisCache() {
-		return new RedisCache<String, Object>(redisTemplate);
-	}
 }

+ 0 - 13
mec-web/src/main/java/com/ym/mec/web/WebApplication.java

@@ -1,21 +1,17 @@
 package com.ym.mec.web;
 
 import org.mybatis.spring.annotation.MapperScan;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.client.loadbalancer.LoadBalanced;
 import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.web.client.RestTemplate;
 
 import com.spring4all.swagger.EnableSwagger2Doc;
-import com.ym.mec.common.redis.service.RedisCache;
 
 @SpringBootApplication
 @EnableDiscoveryClient
@@ -26,9 +22,6 @@ import com.ym.mec.common.redis.service.RedisCache;
 @EnableSwagger2Doc
 public class WebApplication {
 
-	@Autowired
-	private RedisTemplate<String, Object> redisTemplate;
-	
 	public static void main(String[] args) {
 		SpringApplication.run(WebApplication.class, args);
 	}
@@ -38,10 +31,4 @@ public class WebApplication {
 	public RestTemplate restTemplate() {
 		return new RestTemplate();
 	}
-
-	@Bean
-	@ConditionalOnBean(RedisTemplate.class)
-	public RedisCache<String, Object> redisCache() {
-		return new RedisCache<String, Object>(redisTemplate);
-	}
 }

+ 18 - 0
mec-workflow/src/main/resources/application.yml

@@ -34,6 +34,24 @@ spring:
     poolPreparedStatements: true
     maxOpenPreparedStatements: 20
     
+  redis:
+    host: 120.26.238.168
+    port: 6379
+    password: ehjinrong
+    database: 0
+    #连接超时时间(毫秒)
+    timeout: 10000
+    jedis:
+      pool:
+        #连接池最大连接数(使用负值表示没有限制)
+        max-active: 10
+        #连接池最大阻塞等待时间(使用负值表示没有限制)
+        max-wait: -1
+        #连接池中的最大空闲连接
+        max-idle: 10
+        #连接池中的最小空闲连接
+        min-idle: 1
+    
 
 mybatis:
     mapperLocations: classpath:config/mybatis/*.xml

+ 0 - 6
pom.xml

@@ -177,12 +177,6 @@
 				<version>${google.zxing.version}</version>
 			</dependency>
 
-			<dependency>
-				<groupId>org.apache.commons</groupId>
-				<artifactId>commons-pool2</artifactId>
-				<version>2.6.2</version>
-			</dependency>
-
 		</dependencies>
 	</dependencyManagement>