Tag: spring

弹簧和multithreading

我需要启动一个可变数量的线程,这些线程又会在spring应用程序中启动不同数量的线程(即I线程需要启动Ki线程的线程)。 假设每个“I线程”包含一个自动assembly的内部类,我将如何生成这些实例? 所以我有一个A bean需要以某种方式生成I需要进行Spring管理以满足其依赖关系的bean实例。 我写了一个简短的示例代码,我认为是我的解决方案的基础,我已经标记了代码,我不知道如何编写???: @Component public class MasterOrchestrator { public void do(List list){ ExecutorService es = Executors.newFixedThreadPool(list.size()); for (DataObjWrapper dataObjWrapper : list){ es.submit(???); } } } @Component public class ThreadWorkerI implements Runnable{ private int numThreadsForMessageType; private int numRunsForMessageType; private DataObj dataObj; public ThreadWorkerI(int numThreadsForMessageType, int numRunsForMessageType, DataObj dataObj){ this.numThreadsForMessageType = numThreadsForMessageType; this.numRunsForMessageType = numRunsForMessageType; […]

如何在Spring中的请求参数中发送特殊字符

如何处理请求参数中的特殊字符? 这是我的控制器: @Scope(“request”) @RestController public class GetOperatorSeries{ @RequestMapping(value = “test”, method = RequestMethod.GET) public String getOperatorSeries(HttpServletResponse response, @RequestParam(value = “mobno”) long mobno, @RequestParam(value = “sourceType”) String sourceType, @RequestParam(value = “responseType”) String responseType) { } 例如,如果我在请求参数中使用任何特殊字符,则它不会读取它,就像我发送“sourceType = @ $ abc”那样它会将其读为null或为空。 但我希望它也应该读特殊字符。

如何避免在高可用性集群JBoss EAP中运行重复任务

我正在开发一个需要有一些后台工作的应用程序,例如在挂起的警报上发送电子邮件。 在独立配置中,作业已配置好并且可以与Spring调度程序和计划任务一起正常工作。 但我不知道如何使它们在具有高可用性的JBoss环境的集群上同步。 主要问题是避免不同节点上的作业同时运行。 我读过有关Quartz的内容: http://quartz-scheduler.org/documentation/quartz-2.x/configuration/ConfigJDBCJobStoreClustering 但是,在高可用性方案中并没有建议: 永远不要在不同的机器上运行群集,除非它们的时钟使用某种forms的时间同步服务(守护进程)进行同步,这些服务定期运行(时钟必须在彼此的秒内)。 如果您不熟悉如何执行此操作,请访问http://www.boulder.nist.gov/timefreq/service/its.htm 。 到目前为止,我已经使用自制的阻塞系统解决了同步问题( 为什么我在使用Oracle的JPA中的悲观锁定不起作用 )。 但我想知道JBoss是否为这个当然常见的问题提供了一些解决方案。

用spring反序列化JSON:未解析的前向引用Jackson Exception

我在Spring上使用API​​ Rest项目。 我有一个服务“CreateMateriel”,它作为参数数据JSON: 装备对象的JSON { “agence”: 1, “code”: “001”, “type”: “MyType” } “物质”与“Agence”有很多关系。 我把@JsonIdentityInfo标签用来使用Agence的Id而不是Agence的对象(看完这个话题后 ) @JsonIdentityInfo( generator = ObjectIdGenerators.PropertyGenerator.class, property = “idAgence”) @JsonIdentityReference(alwaysAsId = true) @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = “agence”) private Agence agence; 但是当我在POST / materiels上发送JSON时,我有这个例外: 2017-05-16 18:00:53.021 WARN 8080 — [nio-8080-exec-8] .wsmsDefaultHandlerExceptionResolver : Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: […]

将-source设置为1.5,显然设置为1.3

我正在使用eclipse,使用maven2插件。 我正在尝试设置一个简单的注释基于spring 3 mvc web应用程序。 所以我去RunAs并点击’maven build’,我将目标设置为’compile’。 编译时,我收到错误消息: E:\dev\eclipse\springmvc2\src\main\java\web\HomeController.java:[5,1] annotations are not supported in -source 1.3 (use -source 5 or higher to enable annotations) @Controller 到目前为止,我修改了eclipse.ini以使用jdk。 我也确定在偏好下,它是在java 1.6。 不确定在哪里改变java版本? (我假设源1.3意味着java 1.3,我需要它至少兼容1.5版本)

为什么Maven + Spring Boot会创建巨大的jar文件?

我有以下Maven项目结构: parent_project +–main_application +–domain_models_and_repository +–module_1 +–module_2 +–module_3 以下简化的POMS: parent_project.pom [Spring Boot dependencies] main_application domain_models_and_repository module_1 module_2 module_3 org.springframework.boot spring-boot-maven-plugin main_application parent_project domain_models_and_repository module_1 module_2 module_3 module_1 parent_project domain_models_and_repository module_2 parent_project domain_models_and_repository module_3 parent_project domain_models_and_repository module_1 module_2 实际上我有更多的模块,其中更多的是其他人的依赖。 当我运行mvn install我得到一个主应用程序的1.2GB文件。 我注意到所有模块的所有依赖关系都被组装到模块中。 因此,许多jar文件被多次组装到文件中。 我怎么能避免这个?

Spring Oauth2:在SecurityContext中找不到身份validation对象

我有一个项目,我实现了Spring安全性和Spring OAuth2 Security。当我请求访问令牌时,它运行良好但是当我使用访问令牌请求资源时,我得到了“在SecurityContext中找不到身份validation对象”。 我的项目的SecurityContext是: <!– –> <!– –> <!– –> <!– –> <!– –> <!– –> <!– –> 我使用http:// localhost:8060 / oauth / token请求令牌?grant_type =密码&client_id = nokia3320&client_secret = 0987654321&username = subash&password = 123456我得到了以下回复 { “access_token”: “9f5a89ce-a0d9-4d65-8e83-5d3b16d8c025”, “token_type”: “bearer”, “refresh_token”: “c2ac82ec-9f41-46dd-b7c2-4772c018505c”, “expires_in”: 499, “scope”: “read trust write” } 当我尝试使用http:// localhost:8060 / Api / currencyList在authorizatioin错误中使用访问令牌访问资源时,我得到了以下响应 { “error”: […]

Spring Boot YARN无法在Hadoop上运行2.8.0客户端无法访问DataNode

我正在尝试运行Spring Boot YARN示例(Windows上的https://spring.io/guides/gs/yarn-basic/ )。 在application.yml我将fsUri和resourceManagerHost更改为指向我的VM的主机192.168… 但是,当我试图运行应用程序Exceprion出现时: DFSClient: Exception in createBlockOutputStream java.net.ConnectException: Connection timed out: no further information at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) at org.apache.hadoop.net.SocketIOWithTimeout.connect(SocketIOWithTimeout.java:206) at org.apache.hadoop.net.NetUtils.connect(NetUtils.java:531) at org.apache.hadoop.hdfs.DFSOutputStream.createSocketForPipeline(DFSOutputStream.java:1508) at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.createBlockOutputStream(DFSOutputStream.java:1284) at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.nextBlockOutputStream(DFSOutputStream.java:1237) at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.run(DFSOutputStream.java:449) [2017-05-27 19:59:49.570] boot – 7728 INFO [Thread-5] — DFSClient: Abandoning BP-646365587-10.0.2.15-1495898351938:blk_1073741830_1006 [2017-05-27 19:59:49.602] boot – 7728 INFO [Thread-5] — DFSClient: Excluding […]

Spring Batch Java Config事务 – 属性等价

在Spring批处理中,您可以像这样设置事务isolation和propagation : 我找不到相同的java配置。

无法将’org.springframework.batch.item.xml.StaxEventItemWriter’类型的值转换为必需的类型’org.springframework.batch.item.ItemReader’

我正在开发Spring Batch MongoDB to XML示例。 我已经成功创建了这个项目,但是当我运行它时,我看到下面的错误即将来临,我不知道这里出了什么问题。 参考错误 Exception in thread “main” org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘step1’: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type ‘org.springframework.batch.item.xml.StaxEventItemWriter’ to required type ‘org.springframework.batch.item.ItemReader’ for property ‘itemReader’; nested exception is java.lang.IllegalStateException: Cannot convert value of type ‘org.springframework.batch.item.xml.StaxEventItemWriter’ to required type ‘org.springframework.batch.item.ItemReader’ […]