spring-web

Stomp spring web socket message exceeds size limit

为君一笑 提交于 2019-12-08 23:53:41
问题 I am implementing spring web-socket into our spring mvc web application. However I am running into message over size limits when I am trying to send a really big message to an endpoint. I am getting the following error, message:The 'content-length' header 68718 exceeds the configured message buffer size limit 65536 14:49:11,506 ERROR [org.springframework.web.socket.messaging.StompSubProtocolHandler] (http-localhost/127.0.0.1:8080-4) Failed to parse TextMessage payload=[13684590},..],

Backslash (\) in .proprties file is being ignored by Spring's 'Environment' variable

你离开我真会死。 提交于 2019-12-07 14:48:01
问题 I am trying to load a config.proprties file data in a Spring @Configuration java class using @PropertySource and Environment variable. Example: http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/annotation/PropertySource.html Issue is, I have a property which has value like: serverName = abc\xyz When I read this property by using method, String server= env.getProprty("serverName"); System.out.print(server); Value is printed as "abcxyz". Please note that, I tried

Backslash (\\) in .proprties file is being ignored by Spring's 'Environment' variable

微笑、不失礼 提交于 2019-12-06 01:02:22
I am trying to load a config.proprties file data in a Spring @Configuration java class using @PropertySource and Environment variable. Example: http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/annotation/PropertySource.html Issue is, I have a property which has value like: serverName = abc\xyz When I read this property by using method, String server= env.getProprty("serverName"); System.out.print(server); Value is printed as "abcxyz". Please note that, I tried using double backslash like, serverName = abc\\xyz but still it is simply ignoring \ from the value

How to map JSON fields to custom object properties? [duplicate]

那年仲夏 提交于 2019-12-05 18:09:29
问题 This question already has answers here : How to map JSON field names to different object field names? (3 answers) Closed 4 years ago . I have a simple json message with some fields, and want to map it to a java object using spring-web . Problem: my target classes fields are named differently than int he json response. How can I anyhow map them to the object without having to rename the fields in java? Is there some annotation that could be placed here? { "message":"ok" } public class

How to create a non-blocking @RestController webservice in spring?

大兔子大兔子 提交于 2019-12-04 13:55:26
问题 I'm having a @RestController webservice method that might block the response thread with a long running service call. As follows: @RestController public class MyRestController { //could be another webservice api call, a long running database query, whatever @Autowired private SomeSlowService service; @GetMapping() public Response get() { return service.slow(); } @PostMapping() public Response get() { return service.slow(); } } Problem: what if X users are calling my service here? The

Spring CORS controller annotation not working

拟墨画扇 提交于 2019-12-04 05:02:52
I want to allow cross origin requests for one domain. My project uses Spring so I want to take advantage of the new CORS support. I am using version 4.2.0 for all springframework dependencies. I followed the example here https://spring.io/blog/2015/06/08/cors-support-in-spring-framework#disqus_thread and tried the first version. My controller annotations looks like: @CrossOrigin(origins = "http://fiddle.jshell.net/", maxAge = 3600) @Controller @RequestMapping("/rest") public class MyController If I understood correctly the mvc-config is an alternative method. I tried it as well: <mvc:cors>

How to map JSON fields to custom object properties? [duplicate]

倖福魔咒の 提交于 2019-12-04 03:09:11
This question already has an answer here: How to map JSON field names to different object field names? 3 answers I have a simple json message with some fields, and want to map it to a java object using spring-web . Problem: my target classes fields are named differently than int he json response. How can I anyhow map them to the object without having to rename the fields in java? Is there some annotation that could be placed here? { "message":"ok" } public class JsonEntity { //how to map the "message" json to this property? private String value; } RestTemplate rest = new RestTemplate(); rest

how to build console command in spring boot web application using spring shell?

无人久伴 提交于 2019-12-03 16:36:41
问题 I have created restfull web application using spring boot web starter which works well. I am able to access it through urls. But I have requirement to create console command which can compute and store some values at the backend. I want to be able to run console command manually or through bash script. I could not find any documentation on how to integrate spring-shell project in spring boot web application. Also there is no option to choose spring-shell dependency in spring boot starter

How to create a non-blocking @RestController webservice in spring?

孤街浪徒 提交于 2019-12-03 08:45:25
I'm having a @RestController webservice method that might block the response thread with a long running service call. As follows: @RestController public class MyRestController { //could be another webservice api call, a long running database query, whatever @Autowired private SomeSlowService service; @GetMapping() public Response get() { return service.slow(); } @PostMapping() public Response get() { return service.slow(); } } Problem: what if X users are calling my service here? The executing threads will all block until the response is returned. Thus eating up "max-connections", max threads

How to prevent spring-boot autoconfiguration for spring-web?

守給你的承諾、 提交于 2019-12-03 08:16:36
问题 I'm using spring-boot and added spring-web dependency in maven pom, to make use of RestTemplate . Now spring tries to initialize an EmbeddedServletContext . How can I prevent it? Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean. at org.springframework