wangwei 6 жил өмнө
parent
commit
b08b259f1a

+ 30 - 0
examcloud-core-examwork-starter/src/main/java/cn/com/qmth/examcloud/core/examwork/starter/config/PropertiesConfig.java

@@ -0,0 +1,30 @@
+package cn.com.qmth.examcloud.core.examwork.starter.config;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.event.ContextRefreshedEvent;
+
+import cn.com.qmth.examcloud.commons.base.util.PathUtil;
+import cn.com.qmth.examcloud.commons.base.util.PropertiesUtil;
+
+/**
+ * 属性配置
+ *
+ * @author WANGWEI
+ * @date 2018年6月21日
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
+ */
+@Configuration
+public class PropertiesConfig implements ApplicationListener<ContextRefreshedEvent> {
+
+	@Value("${spring.profiles.active}")
+	private String springProfilesActive;
+
+	@Override
+	public void onApplicationEvent(ContextRefreshedEvent event) {
+		String resourceName = "application-" + springProfilesActive + ".properties";
+		PropertiesUtil.configureAndWatch(PathUtil.getResoucePath(resourceName));
+	}
+
+}

+ 32 - 0
examcloud-core-examwork-starter/src/main/java/cn/com/qmth/examcloud/core/examwork/starter/config/Swagger2.java

@@ -0,0 +1,32 @@
+package cn.com.qmth.examcloud.core.examwork.starter.config;
+
+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.service.Contact;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@Configuration
+@EnableSwagger2
+public class Swagger2 {
+
+	@Bean
+	public Docket createRestApi() {
+		return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
+				.apis(RequestHandlerSelectors.basePackage("cn.com.qmth")).paths(PathSelectors.any())
+				.build();
+	}
+
+	private ApiInfo apiInfo() {
+		return new ApiInfoBuilder().title("API doc")
+				.contact(new Contact("qmth", "http://www.qmth.com.cn/", "")).version("xxx")
+				.description("API文档").build();
+	}
+
+}

+ 4 - 0
examcloud-core-examwork-starter/src/main/resources/security-exclusions.conf

@@ -1,3 +1,7 @@
+regexp:.*swagger.*
+regexp:.*docs.*
+regexp:.*webjars.*
+
 [${$rmp.ctr.examwork}/exam][{id}][GET]
 [${$rmp.ctr.examwork}/exam][canNotDel/{id}][PUT]
 [${$rmp.ctr.examwork}/exam][updateExamInfo][PUT]