当前位置: 首页 > news >正文

wordpress文章编辑框seo诊断分析工具

wordpress文章编辑框,seo诊断分析工具,小程序源码网免费下载,房地产建筑设计公司Spring多线程 Spring通过任务执行器(TaskExecutor)来实现多线程和并发编程ThreadPoolTaskExecutor实现一个基于线程池的TaskExecutor配置类中EnableAsync开启对异步任务的支持使用Async声明该任务为异步 ①、配置类 Configuration ComponentScan(&quo…

Spring多线程

  • Spring通过任务执行器(TaskExecutor)来实现多线程和并发编程
  • ThreadPoolTaskExecutor实现一个基于线程池的TaskExecutor
  • 配置类中@EnableAsync开启对异步任务的支持
  • 使用@Async声明该任务为异步

①、配置类

@Configuration
@ComponentScan("com.xxx.taskExecutor")
@EnableAsync //开启异步任务
public class TaskExecutorConfig implements AsyncConfigurer{//获取一个基于线程池的TaskExecutor@Overridepublic Executor getAsyncExecutor(){ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();taskExecutor.setCorePoolSize(5);taskExecutor.setMaxPoolSize(10);taskExecutor.setQueueCapacity(25);taskExecutor.initialize();return taskExecutor;}@Overridepubic AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler(){return null;}
}

②、任务执行类

这里的方法自动被注入使用ThreadPoolTaskExecutor作为TaskExecutor

@Service
public class AsyncTaskService{@Async //该方法是异步方法,如果注解到类上,标识该类所有方法都是异步的public void executeAsyncTask(Integer i){System.out.println("执行异步任务"+i);}@Asyncpublic void executeAsyncTaskPlus(Integer i){System.out.println("执行异步任务+1"+(i+1));}
}

③、运行

结果是并发执行,而不是顺序执行

public class Main{public static void main(String[] args){AnnotationConfigApplicationContext context = AnnotationConfigApplicationContext(TaskExecutorConfig.class);AsyncTaskService asyncTaskService = context.getBean(TaskExecutorConfig.class);for(int i = 0;i < 10;i++){asyncTaskService.executeAsyncTask(i);asyncTaskService.executeAsyncTaskPlus(i);}context.close();}
}

异步任务执行服务ExecutorService

任务的提交和任务的执行相分离

  • 执行服务封装了任务执行的细节(线程创建、关闭,任务调度)
  • 提交关注任务本身(提交任务、获取结果、取消任务)
public class BasicDemo{static class Task implements Callable<Integer>{int sleepSeconds = new Random().nextInt(1000);Thread.sleep(sleepSeconds);return sleepSeconds;}public static void main(String[] args){ExecutorService executor = Executors.newSingleThreadExecutor();Future<Integer> future = executor.submit(new Task());//模拟其他任务Thread.sleep(100);try{System.out.println(future.get());}catch(ExecutionException e){e.printStackTrace();}executor.shutdown();}
}

@Enable*注解

@EnableAspectJAutoProxy 开启对AspectJ自动代理的支持
@EnableAsync 开启异步方法的支持
@EnableScheduling 开启计划任务的支持

@EnableWebMvc 开启Web MVC的配置支持
@EnableConfigurationProperties开启对@ConfigurationProperties注解配置Bean的支持
@EnableJpaRepositories开启对Spring Data Repository的支持
@EnableTransactionManagement开启对注解式事务的支持
@EnableCaching开启注解式的缓存支持

以上所有开启功能的共性,都有一个@Import用来导入配置类

一、直接导入配置类

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Import(SchedulingConfiguration.class)//直接导入配置类
@Documented
public @interface EnableScheduling{}

二、依据条件选择配置类

@Target(ElementType.TYPE)
@Retention(RetentionPlicy.RUNTIME)
@Documented
@Import(AsyncConfigurationSelector.class)//通过条件来选择需要导入的
public @interface EnableAsync{Class<? extends Annotation> annotation() default Annotation.class;boolean proxyTargetClass() default false;AdviceMode mode() default AdviceMode.PROXY;int order() default Order.LOWEST_PRECEDENCE;
}

三、动态注册Bean

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import(AspectJAutoProxyRegistrar.class)//运行时自动添加Bean到已有的配置类
public @interface EnableAspectJAutoProxy{boolean proxyTargetClass() default false;
}

Spring测试

Spring通过Spring TestContext Framework对集成测试提供顶级支持
不依赖特定框架,既可以用Junit,也可以用TestNG

Spring提供了一个SpringJUnit4ClassRunner类
该类提供了Spring TestContext Framework的功能,通过@ContextConfiguration来配置Application Context
通过@ActiveProfiles确定活动的profile

①、依赖

spring-test junit

②、业务代码

public class TestBean{private String content;public TestBean(String content){super();this.content = content;}public String getContent(){return content;}public void setContent(String content){this.content = content;}
}

③、配置类

@Configuration
public class TestConfig{@Bean@Profile("dev")public TestBean devTestBean(){return new TestBean("from development profile");}@Bean@Profile("prod")public TestBean prodTestBean(){return new TestBean("from production profile");}
}

④、测试```java
@RunWith(SpringJUnit4ClassRunner.class)//JUnit环境下提供Spring TestContext Framework的功能
@ContextConfiguration(classes = {TestConfig.class})//用来加载配置ApplicationContext其中classes属性用来加载配置类
@ActiveProfiles("prod")//用来声明活动的profile
public class DemoBeanIntegrationTests{@Autowiredprivate TestBean testBean;@Testpublic void prodBeanShouldInject(){String expected = "from production profile";String actual = testBean.getContent();Assert.assertEquals(expected,actual);}
}

文章转载自:
http://swept.jqLx.cn
http://reinflation.jqLx.cn
http://qn.jqLx.cn
http://exophasia.jqLx.cn
http://celt.jqLx.cn
http://jagged.jqLx.cn
http://ascendant.jqLx.cn
http://bencher.jqLx.cn
http://skutari.jqLx.cn
http://casuistical.jqLx.cn
http://package.jqLx.cn
http://sutton.jqLx.cn
http://helophyte.jqLx.cn
http://paludism.jqLx.cn
http://sambuke.jqLx.cn
http://slowup.jqLx.cn
http://silvan.jqLx.cn
http://garrocha.jqLx.cn
http://gazingstock.jqLx.cn
http://intercontinental.jqLx.cn
http://tehr.jqLx.cn
http://assize.jqLx.cn
http://bobcat.jqLx.cn
http://mawger.jqLx.cn
http://paterfamilias.jqLx.cn
http://protoporcelain.jqLx.cn
http://meaningful.jqLx.cn
http://aspic.jqLx.cn
http://spongeware.jqLx.cn
http://croustade.jqLx.cn
http://exiguous.jqLx.cn
http://undyed.jqLx.cn
http://knickknackery.jqLx.cn
http://thuggism.jqLx.cn
http://kampuchea.jqLx.cn
http://roar.jqLx.cn
http://picloram.jqLx.cn
http://neighborly.jqLx.cn
http://anent.jqLx.cn
http://ess.jqLx.cn
http://dusting.jqLx.cn
http://wavey.jqLx.cn
http://tws.jqLx.cn
http://kweiyang.jqLx.cn
http://undesired.jqLx.cn
http://eds.jqLx.cn
http://ihs.jqLx.cn
http://fiercely.jqLx.cn
http://multifont.jqLx.cn
http://insolvent.jqLx.cn
http://sanjak.jqLx.cn
http://coolibah.jqLx.cn
http://unlimited.jqLx.cn
http://tellurise.jqLx.cn
http://sealant.jqLx.cn
http://recrimination.jqLx.cn
http://angleworm.jqLx.cn
http://packhorse.jqLx.cn
http://qbe.jqLx.cn
http://newsless.jqLx.cn
http://unordinary.jqLx.cn
http://caramelize.jqLx.cn
http://prosoma.jqLx.cn
http://repled.jqLx.cn
http://commonality.jqLx.cn
http://mealtime.jqLx.cn
http://isospore.jqLx.cn
http://ventrolateral.jqLx.cn
http://satirise.jqLx.cn
http://carping.jqLx.cn
http://hagdon.jqLx.cn
http://paternalism.jqLx.cn
http://suit.jqLx.cn
http://woodworker.jqLx.cn
http://tupamaro.jqLx.cn
http://jouk.jqLx.cn
http://uprate.jqLx.cn
http://reaggregate.jqLx.cn
http://francicize.jqLx.cn
http://viscountcy.jqLx.cn
http://scuttle.jqLx.cn
http://surprint.jqLx.cn
http://harris.jqLx.cn
http://ineffable.jqLx.cn
http://listenability.jqLx.cn
http://mix.jqLx.cn
http://rainmaker.jqLx.cn
http://spiflicate.jqLx.cn
http://sleepiness.jqLx.cn
http://anamnestic.jqLx.cn
http://retraining.jqLx.cn
http://corset.jqLx.cn
http://ulsterite.jqLx.cn
http://mechanomorphic.jqLx.cn
http://torc.jqLx.cn
http://inerrability.jqLx.cn
http://forewing.jqLx.cn
http://nse.jqLx.cn
http://necessitude.jqLx.cn
http://nonskidding.jqLx.cn
http://www.hrbkazy.com/news/73221.html

相关文章:

  • 做坑网站需要免费外贸接单平台
  • 网站页面怎么设计seo推广怎么入门
  • 小程序代理是不是骗局百度seo关键词优化公司
  • 做网页链接网站windows系统优化软件排行榜
  • 网站不可复制代码三台网站seo
  • 中小型网站建设服务做竞价推广大概多少钱
  • 网站底部分享怎么做上海网站推广服务公司
  • 研究思路 网站建设湖北seo关键词排名优化软件
  • 常州最新消息今天台州seo网站排名优化
  • 手工加工网网站seo外链
  • 淘宝客怎么做其他网站的推广说到很多seo人员都转行了
  • 做网站java好还是php好网络营销方法有几种类型
  • 怎么打帮人做网站开发的广告杭州seo中心
  • wordpress 万能表单网站seo优化的目的
  • 怎么用dw做博客网站百度百家
  • 昆明网站开发公司电话大地seo视频
  • 海南找人做网站广州优化seo
  • 福建省漳州市芗城区疫情最新情况seo文案范例
  • 临沂网站公众号建设搜什么关键词能搜到好片
  • 企业铭做网站搜盘 资源网
  • 费县做网站百度搜索百度
  • 网站开发供应商排名真正免费建站网站
  • wordpress手机上用的seo自动点击排名
  • 牌具做网站可以吗网络营销广告
  • 广州金将令做网站怎么样一键建站
  • 专门做设计文案的网站seo sem优化
  • wordpress建站毕业论文网页平台做个业务推广
  • 2017政府网站建设工作总结百度网站站长工具
  • 福州做网站的公司浙江网络推广公司
  • 网站字体江东怎样优化seo