草庐IT

index-async

全部标签

java - 如何使用 Mockito 在 Spring Boot 中模拟异步(@Async)方法?

用mockito模拟异步(@Async)方法的最佳方法是什么?提供以下服务:@Service@Transactional(readOnly=true)publicclassTaskService{@Async@Transactional(readOnly=false)publicvoidcreateTask(TaskResourcetaskResource,UUIDlinkId){//dosomeheavytask}}Mockito的验证如下:@RunWith(SpringRunner.class)@WebMvcTest(SomeController.class)publicclass

java - Spring取消@Async任务

我希望能够在它的future取消标有@Async注释的方法。我有一个用@Async注释标记的Spring方法。该方法进行一些计算,并最终返回一个结果。我见过的所有示例都建议使用AsyncResult类来返回此Future。@AsyncpublicFuturerun(){//...Computation.Minutespass...returnnewAsyncResult("Result");}我以下列方式从另一个组件调用以下方法。出于示例目的,我希望立即取消此线程:Futurefuture=component.run();future.cancel(true);在这种情况下,线程永远不

java - Spring 安全 : java. sql.SQLException : Column Index out of range, 3 > 2

我正在使用spring4,我想使用springsecurity3来控制我的登录表单。所以我在数据库中有以下表格:用户表:CREATETABLEIFNOTEXISTS`users`(idINT(11)NOTNULLAUTO_INCREMENT,nameVARCHAR(45)NOTNULL,passwordVARCHAR(45)NOTNULL,emailVARCHAR(45)NOTNULL,enabledTINYINTNOTNULLDEFAULT1,PRIMARYKEY(id),UNIQUEKEYuni_name_email_key(name,email))ENGINE=InnoDB;角色

java - 如何为 Async Spring 使用多个 threadPoolExecutor

我在两个类上使用Spring@Async。两者最终都实现了一个接口(interface)。我正在创建两个单独的ThreadPoolTask​​Executor,因此每个类都有自己的ThreadPool来处理。然而,由于我认为代理和Spring如何实现异步类,我必须将@Async注释放在基本接口(interface)上。因此,这两个类最终使用相同的ThreadPoolTask​​Executor。是否可以告诉Spring对于这个Bean(在本例中我将实现该接口(interface)的类称为服务),使用这个ThreadPoolTask​​Executor。 最佳

java - Apache async HttpClient 速度不快

我是Apachehttp客户端的新手,正在尝试从网站获取状态代码。在Apachehttp教程中找到以下示例。importjava.util.concurrent.CountDownLatch;importorg.apache.http.HttpResponse;importorg.apache.http.client.config.RequestConfig;importorg.apache.http.client.methods.HttpGet;importorg.apache.http.concurrent.FutureCallback;importorg.apache.http.

java - 错误 : The column index is out of range: 1, 列数:0

我正在尝试解决向Postgresql表中插入的问题我看了这个类似的问题,但没有解决我的问题ERROR:Thecolumnindexisoutofrange:1,numberofcolumns:0这里是出现错误的部分代码:Stringquery="INSERTINTOreviews(nbstar,body,author,product_id)VALUES($1,$2,$3,$4)";PreparedStatementprepareStatement=connection.prepareStatement(query);prepareStatement.setInt(1,nbStar);p

java - Missing IN or OUT parameter at index::1 java, Oracle 中的错误

您好,我使用Netbeans8.0.2和Oracle11gExpressEdition在JSF2.2中编写了一个图书馆管理系统。我有几个名为Books、Borrowers等的页面和一些在数据库中命名为相同的表。我的问题是:在Borrowers屏幕中显示了图书ID。但我想获得具有相同ID的书名。这是我的代码。publicListgetBorrowers()throwsClassNotFoundException,SQLException,InstantiationException,IllegalAccessException{Class.forName("oracle.jdbc.dri

java - 获取 BitSet 中集合位的所有 Index

我正在寻找一种快速算法,为我提供BitSet对象中设置位的所有索引。这很慢:BitSetbitSet=...Collectionindexes=newArrayList(bitSet.cardinality());intnextSetBit=bitSet.nextSetBit(0);for(inti=0;i感谢任何帮助! 最佳答案 根本不需要使用bitSet.cardinality():for(inti=bitSet.nextSetBit(0);i!=-1;i=bitSet.nextSetBit(i+1)){indexes.add(

java - java.sql.SQLException :[Microsoft][ODBC Driver Manager] Invalid descriptor index 异常

我使用下面的代码try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");Connectioncon=DriverManager.getConnection("jdbc:odbc:access");Stringsql="Select*fromtable";Statementstmt=con.createStatement();ResultSetrs=stmt.executeQuery(sql);ResultSetMetaDatamd=rs.getMetaData();intcolumns=md.getColumnCount();for(inti

google-app-engine - App Engine 批量加载程序下载警告 "No descending index on __key__, performing serial download"

我正在使用以下内容下载我的一种的所有实例:appcfg.pydownload_data--config_file=bulkloader.yaml--kind=ModelName--filename=ModelName.csv--url=http://appid.appspot.com/remote_api如果种类的实例数多于批量大小,那么我会收到此警告:Nodescendingindexon__key__,performingserialdownload我没有任何自定义索引,也没有任何禁用索引的属性。我“需要”做些什么来解决这个警告,还是它只是一个我可以放心忽略的警告?会影响下载速度吗