| | |
| | | import com.java110.doc.registrar.ApiDocPublishing; |
| | | import com.java110.intf.dev.ICacheV1InnerServiceSMO; |
| | | import com.java110.service.init.ServiceStartInit; |
| | | import com.java110.utils.cache.MappingCache; |
| | | import com.java110.utils.constant.MappingConstant; |
| | | import com.java110.utils.factory.ApplicationContextFactory; |
| | | import com.java110.utils.util.StringUtil; |
| | | import okhttp3.ConnectionPool; |
| | |
| | | import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; |
| | | import org.springframework.http.converter.StringHttpMessageConverter; |
| | | import org.springframework.scheduling.annotation.EnableAsync; |
| | | import org.springframework.scheduling.annotation.EnableScheduling; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.nio.charset.Charset; |
| | |
| | | * 这个服务是将 系统部署为spring boot版 |
| | | * 如果是spring cloud 微服务部署 不用启动这个类 |
| | | * <p> |
| | | * excludeName = { |
| | | * "com.java110.intf.acct", |
| | | * "com.java110.intf.code", |
| | | * "com.java110.intf.common", |
| | | * "com.java110.intf.community", |
| | | * "com.java110.intf.demo", |
| | | * "com.java110.intf.dev", |
| | | * "com.java110.intf.fee", |
| | | * "com.java110.intf.goods", |
| | | * "com.java110.intf.job", |
| | | * "com.java110.intf.oa", |
| | | * "com.java110.intf.order", |
| | | * "com.java110.intf.report", |
| | | * "com.java110.intf.store", |
| | | * "com.java110.intf.user" |
| | | * } |
| | | * |
| | | * @version v0.1 |
| | | * @auther com.java110.wuxw |
| | |
| | | }, |
| | | exclude = {LiquibaseAutoConfiguration.class, |
| | | org.activiti.spring.boot.SecurityAutoConfiguration.class, |
| | | org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class} |
| | | org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class, |
| | | com.github.pagehelper.autoconfigure.MapperAutoConfiguration.class |
| | | } |
| | | |
| | | ) |
| | | @Java110CmdDiscovery(cmdPublishClass = ServiceCmdEventPublishing.class, |
| | |
| | | "com.java110.scm.cmd", |
| | | "com.java110.user.cmd" |
| | | }) |
| | | @EnableScheduling |
| | | @EnableAsync |
| | | //文档 |
| | | @Java110ApiDocDiscovery(basePackages = {"com.java110.boot.rest"}, apiDocClass = ApiDocPublishing.class) |
| | |
| | | @Bean |
| | | public OutRestTemplate outRestTemplate() { |
| | | StringHttpMessageConverter m = new StringHttpMessageConverter(Charset.forName("UTF-8")); |
| | | m.setWriteAcceptCharset(false); |
| | | OutRestTemplate restTemplate = new RestTemplateBuilder().additionalMessageConverters(m).build(OutRestTemplate.class); |
| | | restTemplate.getInterceptors().add(java110RestTemplateInterceptor); |
| | | |
| | | //设置超时时间 |
| | | HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory(); |
| | | httpRequestFactory.setConnectionRequestTimeout(5000); |
| | | httpRequestFactory.setConnectTimeout(5000); |
| | | httpRequestFactory.setReadTimeout(5000); |
| | | httpRequestFactory.setConnectionRequestTimeout(10000); |
| | | httpRequestFactory.setConnectTimeout(10000); |
| | | httpRequestFactory.setReadTimeout(10000); |
| | | restTemplate.setRequestFactory(httpRequestFactory); |
| | | return restTemplate; |
| | | } |
| | | |
| | | @Bean |
| | | //@LoadBalanced |
| | | public RestTemplate formRestTemplate() { |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | restTemplate.getMessageConverters().add(new StringHttpMessageConverter(Charset.forName("UTF-8"))); |
| | | return restTemplate; |
| | | } |
| | | |
| | | /** |
| | | * 实例化RestTemplate,通过@LoadBalanced注解开启均衡负载能力. |
| | | * |
| | |
| | | @LoadBalanced |
| | | public RestTemplate restTemplate() { |
| | | StringHttpMessageConverter m = new StringHttpMessageConverter(Charset.forName("UTF-8")); |
| | | m.setWriteAcceptCharset(false); |
| | | RestTemplate restTemplate = new RestTemplateBuilder().additionalMessageConverters(m).build(RestTemplate.class); |
| | | restTemplate.getInterceptors().add(java110RestTemplateInterceptor); |
| | | //设置超时时间 |
| | | HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory(); |
| | | httpRequestFactory.setConnectionRequestTimeout(10000); |
| | | httpRequestFactory.setConnectTimeout(10000); |
| | | httpRequestFactory.setReadTimeout(10000); |
| | | restTemplate.setRequestFactory(httpRequestFactory); |
| | | return restTemplate; |
| | | } |
| | | |
| | |
| | | |
| | | Environment.setSystemStartWay(Environment.SPRING_BOOT); |
| | | |
| | | |
| | | //刷新缓存 |
| | | flushMainCache(args); |
| | | // flushMainCache(args); |
| | | |
| | | //服务启动完成 |
| | | ServiceStartInit.printStartSuccessInfo(); |
| | | |
| | | |
| | | } catch (Throwable e) { |
| | | logger.error("系统启动失败", e); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 刷新主要的缓存 |
| | |
| | | logger.debug("判断是否需要刷新日志,参数 args 为 {}", args); |
| | | |
| | | //因为好多朋友启动时 不加 参数-Dcache 所以启动时检测 redis 中是否存在 java110_hc_version |
| | | //String mapping = MappingCache.getValue("java110_hc_version"); |
| | | //String mapping = MappingCache.getValue(MappingConstant.ENV_DOMAIN,"java110_hc_version"); |
| | | String mapping = ""; |
| | | if (StringUtil.isEmpty(mapping)) { |
| | | ICacheV1InnerServiceSMO devServiceCacheSMOImpl = (ICacheV1InnerServiceSMO) ApplicationContextFactory.getBean(ICacheV1InnerServiceSMO.class); |