浏览代码

修改启动类

wangwei 7 年之前
父节点
当前提交
56e1999b8d

+ 2 - 2
examcloud-core-basic-starter/.springBeans

@@ -1,13 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <beansProjectDescription>
 	<version>1</version>
-	<pluginVersion><![CDATA[3.9.4.201804120850-RELEASE]]></pluginVersion>
+	<pluginVersion><![CDATA[3.9.3.201803200843-RELEASE]]></pluginVersion>
 	<configSuffixes>
 		<configSuffix><![CDATA[xml]]></configSuffix>
 	</configSuffixes>
 	<enableImports><![CDATA[false]]></enableImports>
 	<configs>
-		<config>java:cn.com.qmth.examcloud.core.basic.service.Application</config>
+		<config>java:cn.com.qmth.examcloud.core.basic.starter.CoreBasicApplication</config>
 	</configs>
 	<autoconfigs>
 	</autoconfigs>

+ 54 - 53
examcloud-core-basic-starter/pom.xml

@@ -1,54 +1,55 @@
-<?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">
-	<modelVersion>4.0.0</modelVersion>
-	<parent>
-		<groupId>cn.com.qmth.examcloud.core.basic</groupId>
-		<artifactId>examcloud-core-basic</artifactId>
-		<version>0.1.0</version>
-	</parent>
-
-	<artifactId>examcloud-core-basic-starter</artifactId>
-	<packaging>jar</packaging>
-
-	<dependencies>
-		<dependency>
-			<groupId>cn.com.qmth.examcloud.core.basic</groupId>
-			<artifactId>examcloud-core-basic-api-provider</artifactId>
-			<version>${examcloud.version}</version>
-		</dependency>
-
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-test</artifactId>
-			<scope>test</scope>
-		</dependency>
-		<dependency>
-			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-autoconfigure</artifactId>
-		</dependency>
-	</dependencies>
-
-	<build>
-		<plugins>
-			<plugin>
-				<groupId>org.springframework.boot</groupId>
-				<artifactId>spring-boot-maven-plugin</artifactId>
-				<configuration><!-- 指定该Main Class为全局的唯一入口 -->
-					<mainClass>cn.com.qmth.examcloud.service.core.Application</mainClass>
-					<layout>ZIP</layout>
-					<includeSystemScope>true</includeSystemScope>
-				</configuration>
-			</plugin>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-compiler-plugin</artifactId>
-				<configuration>
-					<source>1.8</source>
-					<target>1.8</target>
-				</configuration>
-			</plugin>
-		</plugins>
-	</build>
-
+<?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">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>cn.com.qmth.examcloud.core.basic</groupId>
+		<artifactId>examcloud-core-basic</artifactId>
+		<version>0.1.0</version>
+	</parent>
+
+	<artifactId>examcloud-core-basic-starter</artifactId>
+	<packaging>jar</packaging>
+
+	<dependencies>
+		<dependency>
+			<groupId>cn.com.qmth.examcloud.core.basic</groupId>
+			<artifactId>examcloud-core-basic-api-provider</artifactId>
+			<version>${examcloud.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-test</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-autoconfigure</artifactId>
+		</dependency>
+	</dependencies>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+				<configuration>
+					<mainClass>cn.com.qmth.examcloud.core.basic.starter.CoreBasicApplication</mainClass>
+					<layout>ZIP</layout>
+					<includeSystemScope>true</includeSystemScope>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<source>1.8</source>
+					<target>1.8</target>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+
 </project>

+ 41 - 41
examcloud-core-basic-starter/src/main/java/cn/com/qmth/examcloud/service/core/AccessControlConfig.java → examcloud-core-basic-starter/src/main/java/cn/com/qmth/examcloud/core/basic/starter/AccessControlConfig.java

@@ -1,41 +1,41 @@
-package cn.com.qmth.examcloud.service.core;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.web.servlet.config.annotation.CorsRegistry;
-import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
-
-import cn.com.qmth.examcloud.common.uac.AccessCtrlInterceptor;
-
-/**
- * prod环境开启权限验证
- * @author ting.yin
- */
-@Configuration
-//@Profile("prod")
-public class AccessControlConfig extends WebMvcConfigurerAdapter {
-
-	@SuppressWarnings("rawtypes")
-	@Autowired
-	RedisTemplate redisTemplate;
-
-	@Bean
-	public AccessCtrlInterceptor getInterceptor() {
-		return new AccessCtrlInterceptor(redisTemplate);
-	}
-
-    @Override
-	public void addInterceptors(InterceptorRegistry registry) {
-		registry.addInterceptor(getInterceptor()).addPathPatterns("/**").excludePathPatterns("/**/swagger-ui.html#/**");
-	}
-	@Override
-	public void addCorsMappings(CorsRegistry registry) {
-		registry.addMapping("/**")
-				.allowedOrigins("*")
-				.allowedMethods("GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "TRACE")
-				.allowedHeaders("*");
-	}
-}
+package cn.com.qmth.examcloud.core.basic.starter;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+
+import cn.com.qmth.examcloud.common.uac.AccessCtrlInterceptor;
+
+/**
+ * prod环境开启权限验证
+ * @author ting.yin
+ */
+@Configuration
+//@Profile("prod")
+public class AccessControlConfig extends WebMvcConfigurerAdapter {
+
+	@SuppressWarnings("rawtypes")
+	@Autowired
+	RedisTemplate redisTemplate;
+
+	@Bean
+	public AccessCtrlInterceptor getInterceptor() {
+		return new AccessCtrlInterceptor(redisTemplate);
+	}
+
+    @Override
+	public void addInterceptors(InterceptorRegistry registry) {
+		registry.addInterceptor(getInterceptor()).addPathPatterns("/**").excludePathPatterns("/**/swagger-ui.html#/**");
+	}
+	@Override
+	public void addCorsMappings(CorsRegistry registry) {
+		registry.addMapping("/**")
+				.allowedOrigins("*")
+				.allowedMethods("GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "TRACE")
+				.allowedHeaders("*");
+	}
+}

+ 63 - 64
examcloud-core-basic-starter/src/main/java/cn/com/qmth/examcloud/service/core/Application.java → examcloud-core-basic-starter/src/main/java/cn/com/qmth/examcloud/core/basic/starter/CoreBasicApplication.java

@@ -1,64 +1,63 @@
-package cn.com.qmth.examcloud.service.core;
-
-import org.slf4j.MDC;
-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.web.client.RestTemplate;
-import org.springframework.web.multipart.MultipartResolver;
-import org.springframework.web.multipart.commons.CommonsMultipartResolver;
-
-import com.qmth.commons.query.dao.impl.BaseQueryDaoImpl;
-
-import cn.com.qmth.examcloud.common.support.logging.ExamCloudLog;
-import cn.com.qmth.examcloud.common.support.logging.ExamCloudLogFactory;
-import cn.com.qmth.examcloud.common.support.logging.SLF4JImpl;
-
-@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)
-@SpringBootApplication
-@EnableEurekaClient
-@EnableFeignClients
-@EnableDiscoveryClient
-@EnableAutoConfiguration(exclude = { MultipartAutoConfiguration.class })
-public class Application {
-
-	private static final ExamCloudLog LOG = ExamCloudLogFactory.getLog(Application.class);
-
-	public static void main(String[] args) throws Exception {
-
-		if (LOG instanceof SLF4JImpl) {
-			// 设置主线程埋点跟踪链
-			MDC.put("TRACE_ID", Thread.currentThread().getName());
-		}
-		SpringApplication.run(Application.class, args);
-	}
-
-	@Bean
-	@LoadBalanced
-	public RestTemplate restTemplate() {
-		return new RestTemplate();
-	}
-
-	// 显示声明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);// 上传文件大小 200M 50*1024*1024
-		return resolver;
-	}
-}
+package cn.com.qmth.examcloud.core.basic.starter;
+
+import org.slf4j.MDC;
+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.web.client.RestTemplate;
+import org.springframework.web.multipart.MultipartResolver;
+import org.springframework.web.multipart.commons.CommonsMultipartResolver;
+
+import com.qmth.commons.query.dao.impl.BaseQueryDaoImpl;
+
+import cn.com.qmth.examcloud.common.support.logging.ExamCloudLog;
+import cn.com.qmth.examcloud.common.support.logging.ExamCloudLogFactory;
+import cn.com.qmth.examcloud.common.support.logging.SLF4JImpl;
+
+@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)
+@SpringBootApplication
+@EnableEurekaClient
+@EnableFeignClients
+@EnableDiscoveryClient
+@EnableAutoConfiguration(exclude = { MultipartAutoConfiguration.class })
+public class CoreBasicApplication {
+
+	private static final ExamCloudLog LOG = ExamCloudLogFactory.getLog(CoreBasicApplication.class);
+
+	public static void main(String[] args) throws Exception {
+
+		if (LOG instanceof SLF4JImpl) {
+			// 设置主线程埋点跟踪链
+			MDC.put("TRACE_ID", Thread.currentThread().getName());
+		}
+		SpringApplication.run(CoreBasicApplication.class, args);
+	}
+
+	@Bean
+	@LoadBalanced
+	public RestTemplate restTemplate() {
+		return new RestTemplate();
+	}
+
+	@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;
+	}
+}

+ 36 - 36
examcloud-core-basic-starter/src/main/java/cn/com/qmth/examcloud/service/core/Swagger2.java → examcloud-core-basic-starter/src/main/java/cn/com/qmth/examcloud/core/basic/starter/Swagger2.java

@@ -1,36 +1,36 @@
-package cn.com.qmth.examcloud.service.core;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import springfox.documentation.builders.ApiInfoBuilder;
-import springfox.documentation.builders.PathSelectors;
-import springfox.documentation.builders.RequestHandlerSelectors;
-import springfox.documentation.service.ApiInfo;
-import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spring.web.plugins.Docket;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
-
-/**
- * Created by songyue on 17/1/12.
- */
-@Configuration
-@EnableSwagger2
-public class Swagger2 {
-    @Bean
-    public Docket createRestApi() {
-        return new Docket(DocumentationType.SWAGGER_2)
-                .apiInfo(apiInfo())
-                .select()
-                .apis(RequestHandlerSelectors.basePackage("cn.com.qmth.examcloud.service.core"))
-                .paths(PathSelectors.any())
-                .build();
-    }
-    private ApiInfo apiInfo() {
-        return new ApiInfoBuilder()
-                .title("考试云平台基础信息接口")
-                .description("基于swagger构建的Restful API")
-                .version("1.0")
-                .build();
-    }
-
-}
+package cn.com.qmth.examcloud.core.basic.starter;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+/**
+ * Created by songyue on 17/1/12.
+ */
+@Configuration
+@EnableSwagger2
+public class Swagger2 {
+    @Bean
+    public Docket createRestApi() {
+        return new Docket(DocumentationType.SWAGGER_2)
+                .apiInfo(apiInfo())
+                .select()
+                .apis(RequestHandlerSelectors.basePackage("cn.com.qmth.examcloud.service.core"))
+                .paths(PathSelectors.any())
+                .build();
+    }
+    private ApiInfo apiInfo() {
+        return new ApiInfoBuilder()
+                .title("考试云平台基础信息接口")
+                .description("基于swagger构建的Restful API")
+                .version("1.0")
+                .build();
+    }
+
+}