|
@@ -1,7 +1,9 @@
|
|
|
package com.qmth.themis.backend;
|
|
|
|
|
|
-import com.qmth.themis.backend.config.DictionaryConfig;
|
|
|
-import com.qmth.themis.common.contanst.Constants;
|
|
|
+import java.io.File;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+
|
|
|
import org.mybatis.spring.annotation.MapperScan;
|
|
|
import org.springframework.boot.SpringApplication;
|
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
@@ -14,40 +16,53 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|
|
import org.springframework.web.multipart.MultipartResolver;
|
|
|
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
|
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
+import com.qmth.themis.backend.config.DictionaryConfig;
|
|
|
+import com.qmth.themis.business.config.SystemConfig;
|
|
|
+import com.qmth.themis.business.constant.SpringContextHolder;
|
|
|
+import com.qmth.themis.common.contanst.Constants;
|
|
|
|
|
|
//import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
|
|
|
|
|
@SpringBootApplication
|
|
|
-@ComponentScan(basePackages = {"com.qmth.themis"})
|
|
|
+@ComponentScan(basePackages = { "com.qmth.themis" })
|
|
|
@MapperScan("com.qmth.themis.business.dao")
|
|
|
//主要就是定义扫描的路径从中找出标识了需要装配的类自动装配到spring的bean容器中,做过web开发的同学一定都有用过@Controller,@Service,@Repository注解,查看其源码你会发现,他们中有一个共同的注解@Component,没错@ComponentScan注解默认就会装配标识了@Controller,@Service,@Repository,@Component注解的类到spring容器中
|
|
|
-@EntityScan(basePackages = {"com.qmth.themis.business.entity"})//用来扫描和发现指定包及其子包中的Entity定义
|
|
|
-@EnableTransactionManagement //spring开启事务支持
|
|
|
-@EnableAsync //开启异步任务
|
|
|
-@EnableCaching//开启缓存注解
|
|
|
+@EntityScan(basePackages = { "com.qmth.themis.business.entity" }) // 用来扫描和发现指定包及其子包中的Entity定义
|
|
|
+@EnableTransactionManagement // spring开启事务支持
|
|
|
+@EnableAsync // 开启异步任务
|
|
|
+@EnableCaching // 开启缓存注解
|
|
|
//@EnableMongoRepositories("com.qmth.themis.backend.mongodb.repository")
|
|
|
public class ThemisBackendApplication {
|
|
|
|
|
|
- public static void main(String[] args) {
|
|
|
- SpringApplication.run(ThemisBackendApplication.class, args);
|
|
|
- }
|
|
|
-
|
|
|
- @Resource
|
|
|
- DictionaryConfig dictionaryConfig;
|
|
|
-
|
|
|
- /**
|
|
|
- * 附件上传配置
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
- @Bean
|
|
|
- public MultipartResolver multipartResolver() {
|
|
|
- CommonsMultipartResolver resolver = new CommonsMultipartResolver();
|
|
|
- resolver.setDefaultEncoding(Constants.CHARSET_NAME);
|
|
|
- resolver.setResolveLazily(true);//resolveLazily属性启用是为了推迟文件解析,以在在UploadAction中捕获文件大小异常
|
|
|
- resolver.setMaxInMemorySize(2);//低于此值,只保留在内存里,超过此阈值,生成硬盘上的临时文件。
|
|
|
- resolver.setMaxUploadSize(200 * 1024 * 1024);//最大200M
|
|
|
- return resolver;
|
|
|
- }
|
|
|
+ public static void main(String[] args) {
|
|
|
+ SpringApplication.run(ThemisBackendApplication.class, args);
|
|
|
+ init();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ DictionaryConfig dictionaryConfig;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 附件上传配置
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Bean
|
|
|
+ public MultipartResolver multipartResolver() {
|
|
|
+ CommonsMultipartResolver resolver = new CommonsMultipartResolver();
|
|
|
+ resolver.setDefaultEncoding(Constants.CHARSET_NAME);
|
|
|
+ resolver.setResolveLazily(true);// resolveLazily属性启用是为了推迟文件解析,以在在UploadAction中捕获文件大小异常
|
|
|
+ resolver.setMaxInMemorySize(2);// 低于此值,只保留在内存里,超过此阈值,生成硬盘上的临时文件。
|
|
|
+ resolver.setMaxUploadSize(200 * 1024 * 1024);// 最大200M
|
|
|
+ return resolver;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void init() {
|
|
|
+ SystemConfig conf=SpringContextHolder.getBean(SystemConfig.class);
|
|
|
+ String tempDir = conf.getProperty("sys.config.tempDataDir");
|
|
|
+ File dir=new File(tempDir);
|
|
|
+ if(!dir.exists()) {
|
|
|
+ dir.mkdirs();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|