فهرست منبع

Merge branch 'master' of http://git.qmth.com.cn/ExamCloud-2/examcloud-core-questions

weiwenhai 7 سال پیش
والد
کامیت
95a13c2301

+ 1 - 18
examcloud-core-questions-api-provider/pom.xml

@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 	<modelVersion>4.0.0</modelVersion>
 	<parent>
 		<artifactId>examcloud-core-questions</artifactId>
@@ -24,20 +23,4 @@
 		</dependency>
 	</dependencies>
 
-
-	<!-- <name>examcloud-core-questions-api-provider</name> FIXME change it 
-		to the project's website <url>http://www.example.com</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
-		<maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> 
-		</properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> 
-		<version>4.11</version> <scope>test</scope> </dependency> </dependencies> 
-		<build> <pluginManagement>lock down plugins versions to avoid using Maven 
-		defaults (may be moved to parent pom) <plugins> <plugin> <artifactId>maven-clean-plugin</artifactId> 
-		<version>3.0.0</version> </plugin> see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging 
-		<plugin> <artifactId>maven-resources-plugin</artifactId> <version>3.0.2</version> 
-		</plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.7.0</version> 
-		</plugin> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.20.1</version> 
-		</plugin> <plugin> <artifactId>maven-jar-plugin</artifactId> <version>3.0.2</version> 
-		</plugin> <plugin> <artifactId>maven-install-plugin</artifactId> <version>2.5.2</version> 
-		</plugin> <plugin> <artifactId>maven-deploy-plugin</artifactId> <version>2.8.2</version> 
-		</plugin> </plugins> </pluginManagement> </build> -->
 </project>

+ 61 - 112
examcloud-core-questions-base/pom.xml

@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 	<modelVersion>4.0.0</modelVersion>
 	<parent>
 		<artifactId>examcloud-core-questions</artifactId>
@@ -20,126 +19,76 @@
 			<groupId>cn.com.qmth.examcloud.commons</groupId>
 			<artifactId>examcloud-commons-dto</artifactId>
 			<version>${examcloud.version}</version>
-		</dependency>	
+		</dependency>
 		<dependency>
-			<groupId>com.h2database</groupId>
-			<artifactId>h2</artifactId>
+			<groupId>com.qmth.commons</groupId>
+			<artifactId>data-sync-rabbit</artifactId>
+			<version>1.0-SNAPSHOT</version>
 		</dependency>
-		
+
 		<dependency>
-            <groupId>org.docx4j</groupId>
-            <artifactId>docx4j</artifactId>
-            <version>3.3.3</version>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.slf4j</groupId>
-                    <artifactId>slf4j-api</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.slf4j</groupId>
-                    <artifactId>slf4j-log4j12</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.docx4j</groupId>
-            <artifactId>docx4j-ImportXHTML</artifactId>
-            <version>3.3.1</version>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.slf4j</groupId>
-                    <artifactId>slf4j-api</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.slf4j</groupId>
-                    <artifactId>slf4j-log4j12</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
+			<groupId>org.docx4j</groupId>
+			<artifactId>docx4j</artifactId>
+			<version>3.3.3</version>
+			<exclusions>
+				<exclusion>
+					<groupId>org.slf4j</groupId>
+					<artifactId>slf4j-api</artifactId>
+				</exclusion>
+				<exclusion>
+					<groupId>org.slf4j</groupId>
+					<artifactId>slf4j-log4j12</artifactId>
+				</exclusion>
+			</exclusions>
+		</dependency>
 		<dependency>
-            <groupId>org.jsoup</groupId>
-            <artifactId>jsoup</artifactId>
-            <version>1.10.2</version>
-        </dependency>
+			<groupId>org.docx4j</groupId>
+			<artifactId>docx4j-ImportXHTML</artifactId>
+			<version>3.3.1</version>
+			<exclusions>
+				<exclusion>
+					<groupId>org.slf4j</groupId>
+					<artifactId>slf4j-api</artifactId>
+				</exclusion>
+				<exclusion>
+					<groupId>org.slf4j</groupId>
+					<artifactId>slf4j-log4j12</artifactId>
+				</exclusion>
+			</exclusions>
+		</dependency>
 		<dependency>
-            <groupId>org.freemarker</groupId>
-            <artifactId>freemarker</artifactId>
-        </dependency>
+			<groupId>org.jsoup</groupId>
+			<artifactId>jsoup</artifactId>
+			<version>1.10.2</version>
+		</dependency>
 		<dependency>
-            <groupId>net.sourceforge.jeuclid</groupId>
-            <artifactId>jeuclid-core</artifactId>
-            <version>3.1.9</version>
-        </dependency>
+			<groupId>org.freemarker</groupId>
+			<artifactId>freemarker</artifactId>
+		</dependency>
 		<dependency>
-            <groupId>net.sf.saxon</groupId>
-            <artifactId>Saxon-HE</artifactId>
-            <version>9.7.0-15</version>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-data-mongodb</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.ansj</groupId>
-            <artifactId>ansj_seg</artifactId>
-            <version>5.1.1</version>
-        </dependency>
-        <dependency>
-		  <groupId>com.upyun</groupId>
-		  <artifactId>java-sdk</artifactId>
-		  <version>3.16</version>
+			<groupId>net.sourceforge.jeuclid</groupId>
+			<artifactId>jeuclid-core</artifactId>
+			<version>3.1.9</version>
+		</dependency>
+		<dependency>
+			<groupId>net.sf.saxon</groupId>
+			<artifactId>Saxon-HE</artifactId>
+			<version>9.7.0-15</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-data-mongodb</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.ansj</groupId>
+			<artifactId>ansj_seg</artifactId>
+			<version>5.1.1</version>
 		</dependency>
-	</dependencies>
-	
-	<!-- <properties>
-		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-		<maven.compiler.source>1.7</maven.compiler.source>
-		<maven.compiler.target>1.7</maven.compiler.target>
-	</properties> -->
-
-	<!-- <dependencies>
 		<dependency>
-			<groupId>junit</groupId>
-			<artifactId>junit</artifactId>
-			<version>4.11</version>
-			<scope>test</scope>
+			<groupId>com.upyun</groupId>
+			<artifactId>java-sdk</artifactId>
+			<version>3.16</version>
 		</dependency>
 	</dependencies>
 
-	<build>
-		<pluginManagement>lock down plugins versions to avoid using Maven 
-				defaults (may be moved to parent pom)
-			<plugins>
-				<plugin>
-					<artifactId>maven-clean-plugin</artifactId>
-					<version>3.0.0</version>
-				</plugin>
-				see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging
-				<plugin>
-					<artifactId>maven-resources-plugin</artifactId>
-					<version>3.0.2</version>
-				</plugin>
-				<plugin>
-					<artifactId>maven-compiler-plugin</artifactId>
-					<version>3.7.0</version>
-				</plugin>
-				<plugin>
-					<artifactId>maven-surefire-plugin</artifactId>
-					<version>2.20.1</version>
-				</plugin>
-				<plugin>
-					<artifactId>maven-jar-plugin</artifactId>
-					<version>3.0.2</version>
-				</plugin>
-				<plugin>
-					<artifactId>maven-install-plugin</artifactId>
-					<version>2.5.2</version>
-				</plugin>
-				<plugin>
-					<artifactId>maven-deploy-plugin</artifactId>
-					<version>2.8.2</version>
-				</plugin>
-			</plugins>
-		</pluginManagement>
-	</build> -->
 </project>

+ 1 - 47
examcloud-core-questions-dao/pom.xml

@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 	<modelVersion>4.0.0</modelVersion>
 	<parent>
 		<artifactId>examcloud-core-questions</artifactId>
@@ -17,50 +16,5 @@
 			<version>${examcloud.version}</version>
 		</dependency>
 	</dependencies>
-	
-	<!-- <dependencies>
-		<dependency>
-			<groupId>junit</groupId>
-			<artifactId>junit</artifactId>
-			<version>4.11</version>
-			<scope>test</scope>
-		</dependency>
-	</dependencies>
 
-	<build>
-		<pluginManagement>lock down plugins versions to avoid using Maven 
-				defaults (may be moved to parent pom)
-			<plugins>
-				<plugin>
-					<artifactId>maven-clean-plugin</artifactId>
-					<version>3.0.0</version>
-				</plugin>
-				see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging
-				<plugin>
-					<artifactId>maven-resources-plugin</artifactId>
-					<version>3.0.2</version>
-				</plugin>
-				<plugin>
-					<artifactId>maven-compiler-plugin</artifactId>
-					<version>3.7.0</version>
-				</plugin>
-				<plugin>
-					<artifactId>maven-surefire-plugin</artifactId>
-					<version>2.20.1</version>
-				</plugin>
-				<plugin>
-					<artifactId>maven-jar-plugin</artifactId>
-					<version>3.0.2</version>
-				</plugin>
-				<plugin>
-					<artifactId>maven-install-plugin</artifactId>
-					<version>2.5.2</version>
-				</plugin>
-				<plugin>
-					<artifactId>maven-deploy-plugin</artifactId>
-					<version>2.8.2</version>
-				</plugin>
-			</plugins>
-		</pluginManagement>
-	</build> -->
 </project>

+ 2 - 64
examcloud-core-questions-service/pom.xml

@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 	<modelVersion>4.0.0</modelVersion>
 	<parent>
 		<artifactId>examcloud-core-questions</artifactId>
@@ -10,74 +9,13 @@
 
 	<artifactId>examcloud-core-questions-service</artifactId>
 	<packaging>jar</packaging>
-	
+
 	<dependencies>
 		<dependency>
 			<groupId>cn.com.qmth.examcloud.core.questions</groupId>
 			<artifactId>examcloud-core-questions-dao</artifactId>
 			<version>${examcloud.version}</version>
 		</dependency>
-		<dependency>
-			<groupId>com.qmth.commons</groupId>
-			<artifactId>data-sync-rabbit</artifactId>
-			<version>1.0-SNAPSHOT</version>
-		</dependency>
-	</dependencies>
-
-
-	<!-- <name>examcloud-core-questions-service</name>
-	FIXME change it to the project's website
-	<url>http://www.example.com</url>
-
-	<properties>
-		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-		<maven.compiler.source>1.7</maven.compiler.source>
-		<maven.compiler.target>1.7</maven.compiler.target>
-	</properties>
-
-	<dependencies>
-		<dependency>
-			<groupId>junit</groupId>
-			<artifactId>junit</artifactId>
-			<version>4.11</version>
-			<scope>test</scope>
-		</dependency>
 	</dependencies>
 
-	<build>
-		<pluginManagement>lock down plugins versions to avoid using Maven 
-				defaults (may be moved to parent pom)
-			<plugins>
-				<plugin>
-					<artifactId>maven-clean-plugin</artifactId>
-					<version>3.0.0</version>
-				</plugin>
-				see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging
-				<plugin>
-					<artifactId>maven-resources-plugin</artifactId>
-					<version>3.0.2</version>
-				</plugin>
-				<plugin>
-					<artifactId>maven-compiler-plugin</artifactId>
-					<version>3.7.0</version>
-				</plugin>
-				<plugin>
-					<artifactId>maven-surefire-plugin</artifactId>
-					<version>2.20.1</version>
-				</plugin>
-				<plugin>
-					<artifactId>maven-jar-plugin</artifactId>
-					<version>3.0.2</version>
-				</plugin>
-				<plugin>
-					<artifactId>maven-install-plugin</artifactId>
-					<version>2.5.2</version>
-				</plugin>
-				<plugin>
-					<artifactId>maven-deploy-plugin</artifactId>
-					<version>2.8.2</version>
-				</plugin>
-			</plugins>
-		</pluginManagement>
-	</build> -->
 </project>

+ 30 - 0
examcloud-core-questions-starter/assembly.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+	<id>distribution</id>
+	<formats>
+		<format>zip</format>
+	</formats>
+	<fileSets>
+		<fileSet>
+			<directory>${project.basedir}/src/main/resources</directory>
+			<outputDirectory>/config</outputDirectory>
+		</fileSet>
+		<fileSet>
+			<directory>${project.basedir}/shell</directory>
+			<excludes>
+				<exclude>start.args</exclude>
+				<exclude>start.vmoptions</exclude>
+			</excludes>
+			<outputDirectory>/</outputDirectory>
+			<fileMode>0777</fileMode>
+		</fileSet>
+	</fileSets>
+	<dependencySets>
+		<dependencySet>
+			<useProjectArtifact>true</useProjectArtifact>
+			<outputDirectory>lib</outputDirectory>
+			<scope>runtime</scope>
+		</dependencySet>
+	</dependencySets>
+</assembly>

+ 6 - 54
examcloud-core-questions-starter/pom.xml

@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 	<modelVersion>4.0.0</modelVersion>
 	<parent>
 		<groupId>cn.com.qmth.examcloud.core.questions</groupId>
@@ -17,12 +16,12 @@
 			<artifactId>examcloud-core-questions-api-provider</artifactId>
 			<version>${examcloud.version}</version>
 		</dependency>
-		
+
 		<dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-test</artifactId>
-            <scope>test</scope>
-        </dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-test</artifactId>
+			<scope>test</scope>
+		</dependency>
 	</dependencies>
 
 	<build>
@@ -69,51 +68,4 @@
 		</plugins>
 	</build>
 
-	<!-- <dependencies>
-		<dependency>
-			<groupId>junit</groupId>
-			<artifactId>junit</artifactId>
-			<version>4.11</version>
-			<scope>test</scope>
-		</dependency>
-	</dependencies>
- -->
-	<!-- <build>
-		<pluginManagement>
-			lock down plugins versions to avoid using Maven
-			defaults (may be moved to parent pom)
-			<plugins>
-				<plugin>
-					<artifactId>maven-clean-plugin</artifactId>
-					<version>3.0.0</version>
-				</plugin>
-				see
-				http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging
-				<plugin>
-					<artifactId>maven-resources-plugin</artifactId>
-					<version>3.0.2</version>
-				</plugin>
-				<plugin>
-					<artifactId>maven-compiler-plugin</artifactId>
-					<version>3.7.0</version>
-				</plugin>
-				<plugin>
-					<artifactId>maven-surefire-plugin</artifactId>
-					<version>2.20.1</version>
-				</plugin>
-				<plugin>
-					<artifactId>maven-jar-plugin</artifactId>
-					<version>3.0.2</version>
-				</plugin>
-				<plugin>
-					<artifactId>maven-install-plugin</artifactId>
-					<version>2.5.2</version>
-				</plugin>
-				<plugin>
-					<artifactId>maven-deploy-plugin</artifactId>
-					<version>2.8.2</version>
-				</plugin>
-			</plugins>
-		</pluginManagement>
-	</build> -->
 </project>

+ 1 - 0
examcloud-core-questions-starter/shell/start.args

@@ -0,0 +1 @@
+--spring.profiles.active=test

+ 27 - 0
examcloud-core-questions-starter/shell/start.sh

@@ -0,0 +1,27 @@
+#!/bin/bash
+
+APP_MAIN_JAR="examcloud-core-basic-starter-2.0-SNAPSHOT.jar"
+
+FILE_PATH=$(cd `dirname $0`; pwd)
+
+JAVA_OPTS=`cat $FILE_PATH/start.vmoptions`
+APP_ARGS=`cat $FILE_PATH/start.args`
+
+PID_LIST=`ps -ef|grep $APP_MAIN_JAR|grep java|awk '{print $2}'`
+
+if [ ! -z "$PID_LIST" ]; then
+    echo "[ERROR] : APP is already running!"
+    exit -1
+fi
+
+echo "java options:"
+echo "$JAVA_OPTS"
+echo "args:"
+echo "$APP_ARGS"
+    
+nohup java $JAVA_OPTS -jar $FILE_PATH/lib/$APP_MAIN_JAR $APP_ARGS >/dev/null 2>&1 &
+
+echo "starting......"
+
+exit 0
+

+ 1 - 0
examcloud-core-questions-starter/shell/start.vmoptions

@@ -0,0 +1 @@
+-server -Xms2g -Xmx2g

+ 18 - 0
examcloud-core-questions-starter/shell/stop.sh

@@ -0,0 +1,18 @@
+#!/bin/bash
+
+APP_MAIN_JAR="examcloud-core-basic-starter-2.0-SNAPSHOT.jar"
+
+FILE_PATH=$(cd `dirname $0`; pwd)
+
+PID_LIST=`ps -ef|grep $APP_MAIN_JAR|grep java|awk '{print $2}'`
+
+if [ ! -z "$PID_LIST" ]; then
+    echo "Runnable jar is $APP_MAIN_JAR."
+    for PID in $PID_LIST 
+    do
+        kill -9 $PID
+    done
+    echo "stopped !"
+fi
+
+exit 0

+ 75 - 29
examcloud-core-questions-starter/src/main/java/cn/com/qmth/examcloud/core/questions/starter/Application.java

@@ -1,54 +1,100 @@
 package cn.com.qmth.examcloud.core.questions.starter;
 
-import cn.com.qmth.examcloud.core.questions.base.GridFSUtil;
-
-import com.qmth.commons.query.dao.impl.BaseQueryDaoImpl;
-
+import org.slf4j.MDC;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.domain.EntityScan;
 import org.springframework.boot.autoconfigure.web.MultipartAutoConfiguration;
-import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.client.loadbalancer.LoadBalanced;
 import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
 import org.springframework.cloud.netflix.feign.EnableFeignClients;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+import org.springframework.web.client.RestTemplate;
 import org.springframework.web.multipart.MultipartResolver;
 import org.springframework.web.multipart.commons.CommonsMultipartResolver;
 
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.qmth.commons.query.dao.impl.BaseQueryDaoImpl;
+
+import cn.com.qmth.examcloud.commons.base.logging.ExamCloudLog;
+import cn.com.qmth.examcloud.commons.base.logging.ExamCloudLogFactory;
+import cn.com.qmth.examcloud.commons.base.logging.SLF4JImpl;
+import cn.com.qmth.examcloud.commons.web.redis.RedisClient;
+import cn.com.qmth.examcloud.commons.web.redis.RedisClientImpl;
+import cn.com.qmth.examcloud.core.questions.base.GridFSUtil;
+
 /**
  * 项目入口主程序
  *
  */
-@ComponentScan(basePackages = { "cn.com.qmth"})
-@EntityScan(basePackages = { "cn.com.qmth"})
-@EnableJpaRepositories(basePackages = {
-		"cn.com.qmth"})
+@ComponentScan(basePackages = { "com.qmth.commons", "cn.com.qmth" })
+@EntityScan(basePackages = { "com.qmth.commons", "cn.com.qmth" })
+@EnableJpaRepositories(basePackages = { "com.qmth.commons",
+		"cn.com.qmth" }, repositoryBaseClass = BaseQueryDaoImpl.class)
+@EnableMongoRepositories("cn.com.qmth.examcloud.core.questions.dao")
 @SpringBootApplication
 @EnableEurekaClient
-@EnableFeignClients
-@EnableDiscoveryClient
-@EnableAutoConfiguration
+@EnableFeignClients(basePackages = { "cn.com.qmth.examcloud.core.questions.service.rpc" })
+@EnableAutoConfiguration(exclude = { MultipartAutoConfiguration.class })
 public class Application {
 
-    @Autowired
-    GridFSUtil gridFSUtil;
-
-    public static void main(String[] args) {
-        SpringApplication.run(Application.class, args);
-    }
-
-    // 显示声明CommonsMultipartResolver为mutipartResolver
-    @Bean(name = "multipartResolver")
-    public MultipartResolver multipartResolver() {
-        CommonsMultipartResolver resolver = new CommonsMultipartResolver();
-        resolver.setDefaultEncoding("UTF-8");
-        resolver.setResolveLazily(true);// resolveLazily属性启用是为了推迟文件解析,以在在UploadAction中捕获文件大小异常
-        resolver.setMaxInMemorySize(40960);
-        resolver.setMaxUploadSize(200 * 1024 * 1024);// 上传文件大小 50M 50*1024*1024
-        return resolver;
-    }
+	private static final ExamCloudLog LOG = ExamCloudLogFactory.getLog(Application.class);
+	@Autowired
+	GridFSUtil gridFSUtil;
+
+	public static void main(String[] args) {
+		if (LOG instanceof SLF4JImpl) {
+			MDC.put("TRACE_ID", Thread.currentThread().getName());
+		}
+
+		SpringApplication.run(Application.class, args);
+	}
+
+	@Bean
+	@LoadBalanced
+	public RestTemplate restTemplate() {
+		return new RestTemplate();
+	}
+
+	@Bean
+	public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
+		RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
+		redisTemplate.setConnectionFactory(redisConnectionFactory);
+		Jackson2JsonRedisSerializer<?> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);
+		ObjectMapper objectMapper = new ObjectMapper();
+		objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
+		objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
+		jackson2JsonRedisSerializer.setObjectMapper(objectMapper);
+		redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);
+		redisTemplate.setKeySerializer(new StringRedisSerializer());
+		redisTemplate.afterPropertiesSet();
+		return redisTemplate;
+	}
+
+	@Bean
+	@Autowired
+	public RedisClient redisClient(RedisTemplate<String, Object> redisTemplate) {
+		return new RedisClientImpl(redisTemplate);
+	}
+
+	@Bean(name = "multipartResolver")
+	public MultipartResolver multipartResolver() {
+		CommonsMultipartResolver resolver = new CommonsMultipartResolver();
+		resolver.setDefaultEncoding("UTF-8");
+		resolver.setResolveLazily(true);
+		resolver.setMaxInMemorySize(40960);
+		resolver.setMaxUploadSize(200 * 1024 * 1024);
+		return resolver;
+	}
 }

+ 8 - 8
examcloud-core-questions-starter/src/main/resources/application-dev.properties

@@ -20,14 +20,14 @@ upyun.zipDirectory=paperZipDirectory
 upyun.radioType=mp3,wma
 
 
-#spring.datasource.url=jdbc:mysql://192.168.10.30:3306/exam_cloud_test?useUnicode=true&characterEncoding=UTF-8
-#spring.datasource.username=root
-#spring.datasource.password=root
-#spring.datasource.validation-query=SELECT 1 FROM DUAL
-#spring.datasource.test-on-borrow=true
-#spring.datasource.driver-class-name=com.mysql.jdbc.Driver
-#spring.jpa.show-sql=false
-#spring.jpa.hibernate.ddl-auto=update
+spring.datasource.url=jdbc:mysql://192.168.10.30:3306/exam_cloud_test?useUnicode=true&characterEncoding=UTF-8&useSSL=false
+spring.datasource.username=root
+spring.datasource.password=root
+spring.datasource.validation-query=SELECT 1 FROM DUAL
+spring.datasource.test-on-borrow=true
+spring.datasource.driver-class-name=com.mysql.jdbc.Driver
+spring.jpa.show-sql=false
+spring.jpa.hibernate.ddl-auto=update
 
 
 spring.rabbitmq.host=192.168.10.30

+ 7 - 17
pom.xml

@@ -11,23 +11,13 @@
 	<packaging>pom</packaging>
 
 	<modules>
-		<module>cqb-starter</module>
-		<module>cqb-question-resource</module>
-		<module>cqb-base</module>
-		<module>cqb-gen-paper</module>
-		<module>cqb-flow-core</module>
-		<module>cqb-flow-college</module>
-		<module>cqb-flow-zk</module>
-		<module>cqb-comm-utils</module>
-		<module>cqb-paper</module>
-    <module>examcloud-core-questions-base</module>
-    <module>examcloud-core-questions-starter</module>
-    <module>examcloud-core-questions-api</module>
-    <module>examcloud-core-questions-api-client</module>
-    <module>examcloud-core-basic-questions-provider</module>
-    <module>examcloud-core-questions-api-provider</module>
-    <module>examcloud-core-questions-dao</module>
-    <module>examcloud-core-questions-service</module>
+		<module>examcloud-core-questions-base</module>
+		<module>examcloud-core-questions-starter</module>
+		<module>examcloud-core-questions-api</module>
+		<module>examcloud-core-questions-api-client</module>
+		<module>examcloud-core-questions-api-provider</module>
+		<module>examcloud-core-questions-dao</module>
+		<module>examcloud-core-questions-service</module>
 	</modules>
 
 </project>